Posts

Showing posts from August, 2012

Get width height of image using Varien-image class in Magento

You can get width height of image using Varien_Image (lib/Varien/Image.php) class object. In this example, I assume that your image is present inside media directory of your magento installation. $imagePath = YOUR_IMAGE_PATH_LINK; // like http://example.com/media/myfolder/myimage.jpg // changing url link of image into directory link $dirImg = Mage::getBaseDir().str_replace("/",DS,strstr($imagePath,'/media')); // getting image width and height if (file_exists($dirImg)) { $imageObj = new Varien_Image($dirImg); $width = $imageObj->getOriginalWidth(); $height = $imageObj->getOriginalHeight(); echo $width." x ".$height; } else { echo "File doesn't exist."; } Resize Image <?php echo $this ->helper( 'catalog/image' )->init( $_product , 'image' ) ->constrainOnly(TRUE) ->keepAspectRatio(TRUE) ->keepFrame(FALSE) ->resize(600,null) ?> Fixed h

Jquery how to cause action after image src is changed and loaded

  So I have a script that changes the main image src when a thumbnail is clicked on. This is all good and well, except that occasionally the image doesn't load immediately when it is clicked on. Essentially how do I know when the new image is loaded from the src change. Here is the line of code I have that changes the source: $thumbnail_image_src = $ ( this ). find ( '.thumbnail-image' ). attr ( "data-full" ); Bind a handler to the 'load' event for the img tag ( this JSFiddle )  $ ( this ). find ( '.thumbnail-image' ). each ( function () {    $ ( this ). load ( function () {      alert ( 'image has changed and loaded' );     })     . error ( function () {      alert ( 'image has failed to load' );     }). attr ( 'src' , $ ( this ). attr ( 'data-full' ));   }); These functions will fire at the appropriate events. Enjoy! http://

image fun

http://www.phpied.com/image-fun-with-php-part-2/