I am using Expressionengine 2. I would like to check to see if the file description is not empty so that if there is any content it will be used instead of the entry title in the alt tag.
我正在使用Expressionengine 2.我想查看文件描述是否为空,这样如果有任何内容,将使用它而不是alt标签中的条目标题。
Currently I have the code below which brings in the entry title but I can't work out how I get the logic in place to check the existence of descriptive text for the file (image):
目前我有下面的代码带来了条目标题,但我无法弄清楚我是如何得到逻辑来检查文件(图像)的描述性文本的存在:
<img class="aClass" src="{work_detail_extra_image_01}"
alt="
{if work_detail_extra_image_01:description != ""}
{work_detail_extra_image_01}{description}{/work_detail_extra_image_01}
{if:else}
{title}
{/if}
"
border="0" />
Thanks for taking a look
谢谢参观
2 个解决方案
#1
Try removing != ""
so that line becomes:
尝试删除!=“”以使该行变为:
{if work_detail_extra_image_01:description}.
It'll see if it exists or not.
它会看是否存在。
I'd try to display the description there first without conditionals to make sure they aren't your problem.
我会尝试在没有条件的情况下首先显示描述,以确保它们不是您的问题。
#2
Try this:
<img class="aClass" src="{work_detail_extra_image_01}"
alt="{work_detail_extra_image_01}
{if work_detail_extra_image_01:description != ""}
{work_detail_extra_image_01:description}
{if:else}
{title}
{/if}
{/work_detail_extra_image_01}
"
border="0" />
#1
Try removing != ""
so that line becomes:
尝试删除!=“”以使该行变为:
{if work_detail_extra_image_01:description}.
It'll see if it exists or not.
它会看是否存在。
I'd try to display the description there first without conditionals to make sure they aren't your problem.
我会尝试在没有条件的情况下首先显示描述,以确保它们不是您的问题。
#2
Try this:
<img class="aClass" src="{work_detail_extra_image_01}"
alt="{work_detail_extra_image_01}
{if work_detail_extra_image_01:description != ""}
{work_detail_extra_image_01:description}
{if:else}
{title}
{/if}
{/work_detail_extra_image_01}
"
border="0" />