How to import/create images via Media Manager Class

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!
frimi
Posts: 15
Joined: 02 Oct 2020, 15:25

How to import/create images via Media Manager Class

Post by frimi » 11 Dec 2020, 13:46

Hello

I can create new Media items via
$newMediaItem = $mediaMgr->create();
and add them via a new list item to the desired product - so far, so good
But how do I have to deal with the images itself?
Where should I store the Images?
What should I enter via $newMediaItem->setUrl()?
Is it possible, to enter real URLs to a remote location or is the value to set in the url attribute only a local/relative path?

If iI add Images manually via Backend, they are stored under /httpdocs/uploads/tx_aimeos/files/ and then two levels with strange numbers/letters (0-f)

Thanks for your help and kind regards, Michael

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

Re: How to import/create images via Media Manager Class

Post by aimeos » 14 Dec 2020, 08:27

frimi wrote: 11 Dec 2020, 13:46 Where should I store the Images?
What should I enter via $newMediaItem->setUrl()?
You should store them in a subdirectory of ./uploads/tx_aimeos/. Then, they are part of the 'fs-media' file system and can be accessed by the Aimeos code. Use setUrl() to set the path to the file relative to the ./uploads/tx_aimeos/ directory, e.g.
./uploads/tx_aimeos/images/myproductimage.jpg -> images/myproductimage.jpg
frimi wrote: 11 Dec 2020, 13:46 Is it possible, to enter real URLs to a remote location or is the value to set in the url attribute only a local/relative path?
You can use full qualitifed URLs, a relative path or a "data:" URL.
frimi wrote: 11 Dec 2020, 13:46 If iI add Images manually via Backend, they are stored under /httpdocs/uploads/tx_aimeos/files/ and then two levels with strange numbers/letters (0-f)
The files are distributed over several directories for performance reasons. If you have several thousand files in one directory, many filesystems slow down, so there are 256 subdirectories the files are distributed in.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

frimi
Posts: 15
Joined: 02 Oct 2020, 15:25

Re: How to import/create images via Media Manager Class

Post by frimi » 14 Dec 2020, 18:40

hum, I store the image in a subdirectory as mentoined and set the url relative to uploads/tx_aimeos/

In the backend i see the media item of the product but there is no image shown.

nos3
Posts: 89
Joined: 01 Sep 2015, 13:26

Re: How to import/create images via Media Manager Class

Post by nos3 » 15 Dec 2020, 17:57

Check in the browser console, which URL is used.

Post Reply