Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/templates/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Image Drupal 7在field.tpl.php中获取图像路径_Image_Templates_Drupal 7_Field - Fatal编程技术网

Image Drupal 7在field.tpl.php中获取图像路径

Image Drupal 7在field.tpl.php中获取图像路径,image,templates,drupal-7,field,Image,Templates,Drupal 7,Field,我是Drupal7新手,想知道如何在我的自定义字段主题中获得图像路径 我的字段中有以下内容--field_image_flow.tpl.php文件位于我的主题文件夹中: <div id="Products" class="ContentFlow" style="overflow: visible;"> <!-- should be place before flow so that contained images will be loaded first --> <

我是Drupal7新手,想知道如何在我的自定义字段主题中获得图像路径

我的字段中有以下内容--field_image_flow.tpl.php文件位于我的主题文件夹中:

<div id="Products" class="ContentFlow" style="overflow: visible;">
<!-- should be place before flow so that contained images will be loaded first -->
<div class="loadIndicator" style="position: relative; top: 150px">
    <div class="indicator"></div>
</div>

<div class="flow" style="position: relative; top: 30px">
    <?php 
        foreach ($items as $delta => $item): 
        print render($item); 
        endforeach; 
    ?>
</div>
</div>

<script>
var productsFlow = new ContentFlow('Products', {
                reflectionHeight: 0,
                scaleFactor: 2.3,
                flowSpeedFactor: 0.15,
                onclickActiveItem: function (item) {
                    var activeItem = productsFlow.getActiveItem();
                    var index = productsFlow.items.indexOf(activeItem);
                    $.fancybox.open([
                        <?php 
                            foreach ($items as $delta => $item): 
                                echo "{";   
                                ?????IMAGEPATH????
                                echo "},"; 
                            endforeach; 
                        ?>
                    ], {
                        padding: 0,
                        index: index ? index : 0
                    });
                    return false;
                }
            });
</script>

var productsFlow=新内容流(“产品”{
反射率高度:0,
比例因子:2.3,
流速系数:0.15,
onclickActiveItem:函数(项){
var activeItem=productsFlow.getActiveItem();
var index=productsFlow.items.indexOf(activeItem);
$.fancybox.open([
], {
填充:0,
索引:索引?索引:0
});
返回false;
}
});
如何从foreach循环中的$item中获取imagepath


高级版谢谢。

您可以将图像路径添加到视图中,而不是添加图像。请按照以下步骤执行此操作

1) 从“高级”选项卡向右添加关系。该关系应为所调用文件的fid,例如,如果图像为字段名为图像测试,则要添加的关系为“内容:图像测试:fid”

2) 一旦添加,您将得到一个名为File:Path的字段,这将添加文件的路径。在设置中,您需要选中“显示下载路径而不是文件存储URI”,以便显示实际url

现在,当您使用模板时,您将获得路径,而不是带有img标记的图像

希望有帮助

致意

沙米姆