2

I am trying to display the assets on entries.

  1. I created the assets group.
  2. Uploaded the bunch of images to that group.
  3. Added assets to the entries.

Now I didn't understood how to write a code in templates/index.html to display those images.

Right now I want to understood how to display one image.

Thanks

1 Answer 1

4

Have you tried something like this?

{% set image = entry.myImageFieldHandle.first() %}
<img src='{{image.getUrl()}}' />

Or, if you want a specific image:

{% set image = entry.myImageFieldHandle[3] %}
<img src='{{image.getUrl()}}' />
6
  • What if I added 2 or more assets in one entry..
    – D.M. Vamsi
    Jun 12, 2015 at 3:11
  • In the same field or separate fields? If in the same field you can use the second code snippet above to get the specific image you need by passing in an index. Jun 12, 2015 at 3:13
  • I done like this '<ul class="tools-list"> <li> <a href="#">{% set image = entry.mojorServicesIcons[2] %} <img src='{{image.getUrl()}}' /></a></li> </ul>'
    – D.M. Vamsi
    Jun 12, 2015 at 3:15
  • Images are not displaying
    – D.M. Vamsi
    Jun 12, 2015 at 3:15
  • In the same filed I added 2 assets..
    – D.M. Vamsi
    Jun 12, 2015 at 3:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.