Invision Community 4: SEO, prepare for v5 and dormant account notifications By Matt Monday at 02:04 PM
Ilya Hoilik Posted April 30, 2015 Posted April 30, 2015 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!
opentype Posted May 2, 2015 Posted May 2, 2015 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?
Ilya Hoilik Posted May 2, 2015 Author Posted May 2, 2015 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?
opentype Posted May 2, 2015 Posted May 2, 2015 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}}
Ilya Hoilik Posted May 2, 2015 Author Posted May 2, 2015 @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}}
Recommended Posts
Archived
This topic is now archived and is closed to further replies.