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 resize an image in volts and phtml?

How to resize an image in volts and phtml?



61.2k
edited Dec '15

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



7.1k
edited Dec '15

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

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



31.7k

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;" /> ?



7.1k
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?