Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

how to generating links with a <img> using volt?

how to generating links with a img html tag using volt? such as

<a href="some link">
    <img src="some_image.jpg">
</a>

and i know there is {{ link_to("products/search", "Search") }} and {{ image("img/hello.gif") }}



24.1k

Try replacing "Search" with image("img/hello.gif"), but I think you will need to do your own function for that.



26.1k
Accepted
answer

Try this:

{% set my_image = image('img/hello.gif', 'class':'myClass', 'title':'smellycat') %}

{{ link_to('products/search', my_image) }}


3.6k

thanks for "RompePC" and "Nikolaos Dimopoulos", both of your answers is good, and separate these two tags seems more readable.



3.6k

Try replacing "Search" with image("img/hello.gif"), but I think you will need to do your own function for that.

also thanks for your help!