3

I found some interesting methods in the product model

/**
 * Return re-sized image URL
 *
 * @deprecated since 1.1.5
 * @return string
 */
public function getImageUrl()
{
    return (string)$this->_getImageHelper()->init($this, 'image')->resize(265);
}

/**
 * Return re-sized small image URL
 *
 * @deprecated since 1.1.5
 * @param int $width
 * @param int $height
 * @return string
 */
public function getSmallImageUrl($width = 88, $height = 77)
{
    return (string)$this->_getImageHelper()->init($this, 'small_image')->resize($width, $height);
}

There's also getThumbnailUrl() which work in the same way as getSmallImageUrl()

Unfortunately, the @deprecated doc comment does not say anything about a replacement, so I wonder what should be used instead.

The method is not used in the core and in Magento 1.9 the templates always instantiate the image helper directly.

However, I wonder why I should not use this shortcut and why it has been deprecated in the first place. I'm sure it won't be removed now, if it hasn't been since 1.1.5. getImageUrl() might not be very useful because it resizes to a fixed value, but getSmallImageUrl() and getThumbnailUrl() take $width and $height parameters.

1

1 Answer 1

1

It's what I call stillborn code.

Basically the deprecated flag is not accurate as those methods were not here in 1.1.4 and the deprecated flag has been added with the methods in 1.1.5

My assumption is that it was code from someone who wanted to improve things and never got used.

The only reason I would not use this code is that it returns a string. Thus you cannot make more modifications to the image (aspect ratio, quality, frame, transparency etc...)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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