跳转到主要内容
liangruming 提交于 28 July 2018

views的模板views-view-fields--product.tpl.php,如果自定义图片字段是多图,如何输出呢? 即此field是可上传多张图片的,如何只输出其中的首图呢?

字段名称:field_image_cache 字段类型是图片,只上传多图。 输出代码:<img src="<?php print strip_tags($fields['field_image_cache']->content);?>" />这样是可以输出的。

情况A:如果刚好上张1张图片,完全正确,结果http://localhost/gdesd/sites/default/files/product_images/8_7.jpg 情况B:如果上传N张,就全部输出了如下 abc.jpg,efg.jpg 实例如下 http://localhost/gdesd/sites/default/files/product_images/8_7.jpg,http://localhost/gdesd/sites/default/files/product_images/14_5.jpg

Drupal 版本