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

时间:2013-01-18 10:36:36

标签: image templates drupal-7 field

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

我的字段中有以下内容 - 我的主题文件夹中的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>

如何从foreach循环中的$ item中获取imagepath?

先谢谢你。

1 个答案:

答案 0 :(得分:0)

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

1)从高级选项卡向右添加关系。该关系应该是文件的fid,例如,如果图像是字段,则称为Image Test,那么要添加的关系是“Content:Image Test:fid”

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

现在,当你来到模板时,你会得到路径,而不是带有img标签的图像。

希望能帮助。

最好的问候

斯哈梅埃姆

相关问题