2

How to resize the header logo of magento?? Please reply soon.. I am Working now

<img src="<?php echo $this->getLogoSrc()->resize() ?>" alt="<?php echo $this->getLogoAlt() ?>" />
  • I have an issue with my logo, I followed normal steps: 1. Magento Admin > Content > Configuration > [store] > Header > Logo Image [Upload] 2. Set Logo Image Width and Height, just fill in numbers, no need to use 'px'. 3. Clear Pearl Theme related cache. But unfortunately even if I try to change the px the logo always looks big comparing to the page as you can see here: poykee.com Any idea how to fix this? Which pixel size to use for the logo? Thanks! Clemence – clemence Jan 15 at 9:44
  • If you have a new question, please ask it by clicking the Ask Question button. Include a link to this question if it helps provide context. - From Review – Piyush Jan 15 at 10:05
2

The best way to resize an image in magento isVarien_Image

Follow the below code for resize image
$image = new Varien_Image('/full/fs/path/to/image.jpg');

// you cannot use method chaining with Varien_Image
$image->constrainOnly(false);
$image->keepFrame(true);
// avoid black borders by setting background colour
$image->backgroundColor(array(255,255,255));
$image->keepAspectRatio(true);
$image->resize(216, 139);
$image->save('/full/fs/path/to/save/to.jpg');

more clearly

$_imageUrl = logo die path;
$imageResized = Mage::getBaseDir(‘media’).DS.“resized”.$image;
if (!file_exists($imageResized)&&file_exists($_imageUrl)) :
$imageObj = new Varien_Image($_imageUrl);
$imageObj->constrainOnly(TRUE);
$imageObj->keepAspectRatio(TRUE);
$imageObj->keepFrame(FALSE);
$imageObj->resize(140, 140);
$imageObj->save($imageResized);
endif;
1

Not possible.
Either you add width and height attributes on the <img /> tag, or you put as a logo an image with exactly your desired dimensions. (You can do both).

  • is there any magento function to solve it??? – Arif Apr 10 '14 at 13:35
  • 3
    Read my answer carefully. It starts with 'not possible'. Of course I'm being a little drastic. In theory it is possible but not with what Magento offers. You will have to code everything your self and it's not easy. – Marius Apr 10 '14 at 13:44
0

The Best Way to do it is With CSS, More Easy and More Clean..

If you want a variable image, you can use %..

.logo img{ width: 100%;height: 100%}

0
  1. Find logo.phtml and add an id to tag.
  2. Then add a custom css specifying width and height you want.
-2

Resize the logo with an image editor, use the width, height attributes of the tag, or use css.

  • i want to resize it use functions of magento – Arif Apr 10 '14 at 13:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.