Jump to content

[Solved] $smallSize.width undefined in product.tpl


zwacklmann
 Share

Recommended Posts

$smallSize.height



The Variable is not working in product.tpl. Why is that?

In PrestaShop 1.4.1 the base theme is using the following code in the product.tpl to display the thumbnail images of the product.

getImageLink($product->link_rewrite, $imageIds, 'medium')}" alt="{$image.legend|htmlspecialchars}" height="{$mediumSize.height}" width="{$mediumSize.width}" />



I've changes this to

getImageLink($product->link_rewrite, $imageIds, 'small')}" alt="{$image.legend|htmlspecialchars}" height="{$smallSize.height}" width="{$smallSize.width}" /> 



That didn't do the trick though, as the width and height variables are undefined and result in the images to be displayed in 0x0 size in IE.

Share this post


Link to post
Share on other sites

I think that you shouldn't change that, and instead you may define the width and height you need for mediumSize in preferences->images
If yo think you need to change it, you shoul edit controllers->ProductController.php and insert this code in line 252...

'smallSize' => Image::getSize('small'),

just under

    'mediumSize' => Image::getSize('medium'),


Then you may use smallSize in product.tpl. Notice that you should also change the src of the image to get the small image instead medium one:

src="{$link->getImageLink($product->link_rewrite, $imageIds, 'small')}"


Hope this helps :)

Share this post


Link to post
Share on other sites

You shouldn't modify ProductController.php, use the override folder to create a file ProductController.php in controllers folders with this class :

class ProductController extends ProductControllerCore
{
}



and add in this class the method you want to modify from the original ProductController.php file, and apply midiman fix then. So when you will upgrade your PrestaShop to next version, you won't loose your modifications.

  • Like 1

Share this post


Link to post
Share on other sites

Thank you Raphaël, I didn't know anything about override folder... Is there any place where I can find prestashop's core documentation? Without it, to make any changes is like shooting in the dark... :(

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More