Jump to content
thirty bees forum

Type of image on product page in BO


Quant

Recommended Posts

In the AdminProducts controller we have a small picture type. If this type is not or is it disabled for products?

The initFormAttributes and initFormImages functions have a line that probably does not work correctly:

$type = ImageType::getByNameNType('%', 'products', 'height');
//won't find anything

it's better this way

$type = ImageType::getByNameNType('*', 'products', 'height');
//will show first

In initFormInformations (for inserting pictures in the description), the type small is also hardcoded:

//type (small) as constant
foreach ($images as $k => $image) {
    $images[$k]['src'] = $this->context->link->getImageLink($product->link_rewrite[$this->context->language->id], $product->id.'-'.$image['id_image'], ImageType::getFormatedName('small'));
}

it's better this way

//better to find from what is
$imageType = (ImageType::getImagesTypes('products'))[0]['name'] ?? 'Unknow';
foreach ($images as $k => $image) {
    $images[$k]['src'] = $this->context->link->getImageLink($product->link_rewrite[$this->context->language->id], $product->id.'-'.$image['id_image'], ImageType::getFormatedName($imageType));
}

 

In my store (TB with the latest bleeding edge update) I do not use the "small" type. These fixes work for me. Maybe it should be for everyone.

Link to comment
Share on other sites

15 minutes ago, Traumflug said:

Your "fix" may work for you, and nice to see it does, but is certainly not a general solution. It always picks the first image type defined, which can be any size.

I agree.
In my situation, I could not find a better solution than to write such overrides. Will have to live with them.

Of course, it's better not to delete the small type 😞

Link to comment
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
×
×
  • Create New...