从drupal中的特定目录获取图像

从drupal中的特定目录获取图像,drupal,drupal-files,Drupal,Drupal Files,我是drupal的初学者。我想从drupal中的特定文件夹中获取图像。是否有任何方法可以直接从任何特定的自定义主题中获取drupal图像。您应该只使用来自主题的图像。您可以通过以下方式获得主题的路径: $theme = drupal_get_path('theme',$GLOBALS['theme']); 将其放在使用主题图像的模板文件的顶部。然后在主题模板中,您可以有如下内容: <img src="/<?php echo $theme; ?>/images/my_image

我是drupal的初学者。我想从drupal中的特定文件夹中获取图像。是否有任何方法可以直接从任何特定的自定义主题中获取drupal图像。

您应该只使用来自主题的图像。您可以通过以下方式获得主题的路径:

$theme = drupal_get_path('theme',$GLOBALS['theme']);
将其放在使用主题图像的模板文件的顶部。然后在主题模板中,您可以有如下内容:

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

如果您将主题图像存储在
images
dir…

中,如果本地文件系统上的图像路径数组是您想要的-使用此代码,它应该满足您的需要。获取
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;
        }
    }

我的意思是获取图像URL的路径,或者至少我需要知道如何在自定义主题中加载模块函数