if file exists show it, if not don't show anything
Posted: Thu May 23, 2019 3:34 pm
I'm using this snippet to display file in a div if it exist.
if I write it this way the image is not displaying.
if I write it with " !file_exists " the image is showing.
I have also written it like "{if file_exists($entry->fields.Image2)== false}"
but it gives the same result
Some of my posts have an image in this custom field and others don't.
those how don't have it always shows a broken image.
Is there another way to do this kind of operation or am I misunderstanding something?
Code: Select all
{if file_exists($entry->fields.Image2)}
<div class="col-md-6">
<img src="{$entry->file_location}/{$fields.Image2->displayvalue}{$entry->fields.Image2->displayvalue}" class="img-responsive">
</div>
{/if}
if I write it with " !file_exists " the image is showing.
I have also written it like "{if file_exists($entry->fields.Image2)== false}"
but it gives the same result
Some of my posts have an image in this custom field and others don't.
those how don't have it always shows a broken image.
Is there another way to do this kind of operation or am I misunderstanding something?