How to Change Image Preview Ratio

Questions around the TYPO3 integration and plugins
Forum rules
Always add your TYPO3, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
randomdennis
Posts: 22
Joined: 10 Oct 2024, 12:51

How to Change Image Preview Ratio

Post by randomdennis » 13 Dec 2024, 13:25

Hello, in version 2024 the preview configuration has been moved. Some of my images are no longer scaled 4/3 but 3/4.
I have tried in my extension under config/mshop/media.php
to overwrite:
<?php

return array(
'manager' => array(
'previews' => [
'common' => [[
'maxwidth' => 960,
'maxheight' => 720,
'force-size' => 0,
]],
'catalog' => [
'stage' => [[
'maxwidth' => 960,
'maxheight' => 720,
'force-size' => 0,
]],
],
'product' => [[
'maxwidth' => 960,
'maxheight' => 720,
'force-size' => 0,
]],
],
),
);
I also ran the scale planner and set “--ai-product-image-ratio” to 4/3 in the backend settings, but like 60% of the images are wrong scale

User avatar
aimeos
Administrator
Posts: 8378
Joined: 01 Jan 1970, 00:00

Re: How to Change Image Preview Ratio

Post by aimeos » 16 Dec 2024, 13:14

If you add that to the PHP config file, it's merged into the existing configuration. Then, it's only overwritten if the array key (0, 1, 2, 3) is the same. This doesn't apply if you set the configuration via TypoScript in the scheduler task and for the admin backend module.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

randomdennis
Posts: 22
Joined: 10 Oct 2024, 12:51

Re: How to Change Image Preview Ratio

Post by randomdennis » 17 Dec 2024, 10:50

Apparently it cannot find some pictures although they are available
Scaling media item "10035" failed: Couldn't read file "/uploads/tx_aimeos/1.d/files/f/3/f354eb3f_5x70.jpg"
Last edited by randomdennis on 18 Dec 2024, 14:58, edited 1 time in total.

randomdennis
Posts: 22
Joined: 10 Oct 2024, 12:51

Re: How to Change Image Preview Ratio

Post by randomdennis » 18 Dec 2024, 14:47

What I found is that in Scale/Standard.php, the rescale function always returns a path via getUrl() like this:
files/e/a/ea5f2aee2c2ca9ee3e743f3a9cf8043e.png
However, for some items, I get paths like:
/uploads/tx_aimeos/files/d/9/d96f61617ee606ba537b3f751a9e13c1.jpg
These files are not found or read correctly.

If I use this code in the scale function within typo3conf/ext/aimeos/Resources/Libraries/aimeos/aimeos-core/src/MShop/Media/Manager.php, it works:
if (strncmp($url, '/uploads/tx_aimeos/', 19) === 0) {
$url = substr($url, 19);
}
I’m not sure if this is a specific issue just for us. Thanks again!

Post Reply