Invision Community 4: SEO, prepare for v5 and dormant account notifications Matt November 11, 2024Nov 11
Posted April 30, 201510 yr Hello!I have Files field in my database (only images allowed). What code do I need to insert into a display template to display them? I need to display all files in display page as images (img tag with my custom class)?Thanks!
May 2, 201510 yr That happens by default unless you deactivate the output for the display template in the field settings. Do you mean you want to bypass this automatic display and recreate it in some other way?
May 2, 201510 yr Author Yes. By default it displays like this If I select No formatting it displays like this //website.eu/uploads/monthly_2015_04/40632989.jpg.6de8093c33870d665c9ca0d9b2ffb208.jpg,//website.eu/uploads/monthly_2015_04/37462013.jpg.509f5d739b214b7a2027cdad9c79e5d9.jpg,//website.eu/uploads/monthly_2015_04/30252449.jpg.51d9a871b29bd4e0674d349e9afa2a65.jpg,//website.eu/uploads/monthly_2015_04/37462030.jpg.b51e3678603ee186248399e071358e2d.jpg,//website.eu/uploads/monthly_2015_04/40549882.jpg.51beca6916179587ccbeba23ce9e06a9.jpg,//website.eu/uploads/monthly_2015_04/30265009.jpg.ef52ff0143717ab1cc1eba274811fc54.jpg,//website.eu/uploads/monthly_2015_04/15531406.jpg.d03be5d47ab792287f44b2871b99901a.jpg,//website.eu/uploads/monthly_2015_04/40554092.jpg.fb72f3374efee6df5436eeed2de2e27e.jpg But how I can display just images without any default classes and size limits?
May 2, 201510 yr This should work in the record template. Exchange the XXX with your field ID. {{if $record->field_XXX}} {{$fieldimage = explode(',',$record->field_XXX);}} {{foreach $fieldimage as $element}} <img class="yourclass" src="http:{$element})"> {{endforeach}} {{endif}}
May 2, 201510 yr Author @Ralf H., thank you for help! I edited some lines in your code and it works!{{if $record->customFieldDisplayByKey('FIELD-KEY', 'display')}} {{$fieldimage = explode(',',$record->customFieldDisplayByKey('FIELD-KEY', 'display'));}} {{foreach $fieldimage as $element}} <img class="CUSTOM-CLASS" src="{$element}"> {{endforeach}} {{endif}}
Archived
This topic is now archived and is closed to further replies.