2015-10-08 59 views
0

我是drupal的初学者。我想从drupal中的特定文件夹中提取图像。有没有什么办法直接从任何特定的自定义主题获取Drupal图像。从drupal的特定目录提取图像

+0

我的意思是让图片的网址 –

回答

0

您应该只使用主题中的图片。你可以得到路径,你的主题是这样的:

$theme = drupal_get_path('theme',$GLOBALS['theme']); 

把那即在使用主题图像模板文件的顶部。然后里面你的主题模板,你可以有这样的:

<img src="/<?php echo $theme; ?>/images/my_image.png"> 

如果您保存在里面images目录你的主题图片...

+0

或至少我需要的是如何加载模块模块功能自定义主题的路径 –

0

如果成像路径上的本地文件系统中的数组是你想要的 - 使用这个代码,它应该做你需要的。获取sites/default/files/vegas目录中的所有png jpg gif路径。

//We will use the stream wrapper to access your files directory 
    if ($wrapper = file_stream_wrapper_get_instance_by_uri('public://')) { 

     //Now we can easily get an actual path to that folder 
     $directory = $wrapper->realpath(); 
     //Don't forget to append your "vegas" subfolder here 
     $directory .= DIRECTORY_SEPARATOR . 'vegas' . DIRECTORY_SEPARATOR; 
     $images = glob($directory . "*.{jpg,png,gif}", GLOB_BRACE); 

     foreach($images as $imagePath) 
     { 
      //Do your thing! 
      echo $imagePath; 
     } 
    }