We are moving our forum in GitHub Discussions. For questions about Phalcon v3/v4 you can visit here and for Phalcon v5 here.

How to resize an image in volts and phtml?

How to resize an image in volts and phtml?



85.5k
edited Dec '15

they are display languages so <img src="whatever.jpg" style="widht: 100px; height: 100px;" /> ?



12.2k
edited Dec '15

If you want to resize images when page is rendering you can use something like that https://github.com/elboletaire/Watimage https://phpthumb.sourceforge.net/

Izo's solution do not take into account aspect ratio of the image.



81.1k

Ok, I thought I had some special way Phalcon, I guess with volt use the same syntax

they are display languages so <img src="whatever.jpg" style="widht: 100px; height: 100px;" /> ?



12.2k
Accepted
answer

What first came into my mind:

  • Use https://github.com/elboletaire/Watimage as service, and after that use it from Volt (need cache solutions for resizes images, WatImage can do this if I'm not mistaken out of the box);
  • Resize images at time of uploading to all necessary sizes, it will decrease server's load;
  • Exoctic way, use Zephir to rewrite Watimage class and use as module for PHP;

what if image's width will be more or less than 100 but height will be 100 and vice versa?