We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

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") }}



33.8k

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



39.3k
Accepted
answer

Try this:

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

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


5.0k

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



5.0k

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!