Jump to content

Change size of displayed picture in Order detail BO


malcek

Recommended Posts

./controllers/admin/AdminOrdersController.php

find function:

protected function getProducts($order)
    {
        $products = $order->getProducts();

        foreach ($products as &$product) {
            if ($product['image'] != null) {
                $name = 'product_mini_' . (int) $product['product_id'] . (isset($product['product_attribute_id']) ? '_' . (int) $product['product_attribute_id'] : '') . '.jpg';
                // generate image cache, only for back office
                $product['image_tag'] = ImageManager::thumbnail(_PS_IMG_DIR_ . 'p/' . $product['image']->getExistingImgPath() . '.jpg', $name, 45, 'jpg');
                if (file_exists(_PS_TMP_IMG_DIR_ . $name)) {
                    $product['image_size'] = getimagesize(_PS_TMP_IMG_DIR_ . $name);
                } else {
                    $product['image_size'] = false;
                }
            }
        }

        ksort($products);

        return $products;
    }

Change the function and create a new preview image.

Edited by Guest (see edit history)
Link to comment
Share on other sites

change size to 100 x 100

sample:

protected function getProducts($order)
    {
        $products = $order->getProducts();

        foreach ($products as &$product) {
            if ($product['image'] != null) {
                $name = 'product_mini_' . (int) $product['product_id'] . (isset($product['product_attribute_id']) ? '_' . (int) $product['product_attribute_id'] : '') . '.jpg';
                if (file_exists(_PS_TMP_IMG_DIR_ . $name)) {
                    unlink(_PS_TMP_IMG_DIR_ . $name);
                }
                // generate image cache, only for back office
                $product['image_tag'] = ImageManager::thumbnail(_PS_IMG_DIR_ . 'p/' . $product['image']->getExistingImgPath() . '.jpg', $name, 100, 'jpg');
                if (file_exists(_PS_TMP_IMG_DIR_ . $name)) {
                    $product['image_size'] = getimagesize(_PS_TMP_IMG_DIR_ . $name);
                } else {
                    $product['image_size'] = false;
                }
            }
        }

        ksort($products);

        return $products;
    }

 

Link to comment
Share on other sites

I only added an unlink.
You can also create your own thumbnail.
Just change the name.

Eg

$name = 'product_mini_' . (int) $product['product_id'] . (isset($product['product_attribute_id']) ? '_' . (int) $product['product_attribute_id'] : '') . '_100.jpg';

etc.......

Link to comment
Share on other sites

  • 1 year later...
  • 2 years later...
On 9/7/2021 at 11:27 AM, DARKF3D3 said:

I just found the correct file for PS1.7.7:
/httpdocs/src/Adapter/Order/QueryHandler/GetOrderProductsForViewingHandler.php

Just search for 45 and change to the preferred size.
If you still see the old images, you should delete product_mini images into /img/tmp/ folder.

Hello and thanks for your solution, I found it very practical, do you know if a similar thing can also be done for the products in the products catalogue?

Link to comment
Share on other sites

  • 1 month later...
On 9/23/2023 at 7:32 PM, Luigi Donato said:

Hello and thanks for your solution, I found it very practical, do you know if a similar thing can also be done for the products in the products catalogue?

Image sizes change in the tmp directory, but how to change them on the admin products page?

Now prestashop 8.1.2 shows nail size pictures that I can't identify the products by, especially when they are very similar.

And what do presta developers think that users do not need to recognize the product? why is there no place in the admin config settings where you can change the picture sizes or distances?

Now you have to search for three hours in the files to change the icon size and you can't even find it.

Maybe the prestashop developers think that showing product icons the size of a nail is a very good thing and progress?

Edited by vardenis2 (see edit history)
Link to comment
Share on other sites

On 9/7/2021 at 12:27 PM, DARKF3D3 said:

I just found the correct file for PS1.7.7:
/httpdocs/src/Adapter/Order/QueryHandler/GetOrderProductsForViewingHandler.php

Just search for 45 and change to the preferred size.
If you still see the old images, you should delete product_mini images into /img/tmp/ folder.

Do not working on Prestashop 8.1.2

working this:

change product_mini image size in classes/ImageManager.php by defining $size value.

80 line

Example:

 

Quote

        $size = 250;
        if (!file_exists($image)) {

And change

Quote

$max_x = $size * 3;

to

Quote

$max_x = $size * 1;

 after delete img/tmp

all thumnails in corect size

but images chage olnly in 

index.php/sell/catalog/products/465

how change image size in bo:
/index.php/sell/catalog/products

where are css with class="imgm img-thumbnail"?

I looked through all the css of the admin theme and couldn't find it. And in general, is it possible to change the larger images only on the product administration page, and to leave the smaller ones on the product adjustment page itself? Maybe someone knows how to display product images from the images/p directory on the admin page. Because after increasing the dimensions of the images in the tmp directory, I would have 20,000 product images, the size of which I increase significantly, so it is more relevant for me to show product images from the private image directory.

Edited by vardenis2 (see edit history)
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...