How to Get Real Image Sizes on PHP Level in Magento

June 16, 2014 Andrei Danilchyk Magento
How to Get Real Image Sizes on PHP Level in Magento

Sometimes it is necessary to know the real size of an image before rendering and displaying it on a page. Below you can see the function which returns the array of sizes (such as heigh and width) for a specific image.

Here: $path = Mage::getBaseDir(‘media’) . DS . $this->getMediaDir() . DS . $filename; – full path to the image file

This function is suitable for such modules as Animated Slider and Splashpage.

Here is an example of its usage:



Post a new comment

top