0

How do I get the actual location of the uploaded src file in the file system (var/uploads/[...]) in sulu 1.6?

The Media object itself seems not to give a hint, and the thumbnails are only generated after the src is pulled by the browser, not before.

The reason is, that I want to get the dimensions of an image during page rendering.

Andreas
  • 1,691
  • 1
  • 15
  • 34

2 Answers2

2

In th 1.x release you can use the following class to generate the real file-path of the original file https://github.com/sulu/sulu/blob/master/src/Sulu/Bundle/MediaBundle/Media/Storage/StorageInterface.php#L42

The service id of this class is sulu_media.storage.

This interface will change in 2.x but there you only have to call getPath - so no big deal to upgrade when its released.

  • This looks very promising, I'll give it a shot – Andreas Dec 11 '18 at 18:05
  • I did it via the fileVersion like this: `$absPath = $this->container->get('sulu_media.storage')->load($fileVersion->getName(), $fileVersion->getVersion(), $fileVersion->getStorageOptions());` – Andreas Dec 11 '18 at 18:25
0

You've already read the part of the image configuration? http://docs.sulu.io/en/latest/book/image-formats.html

After that you can access this configured formats: http://docs.sulu.io/en/latest/book/twig.html#images

trickreich
  • 190
  • 1
  • 7
  • Yes, that will give the processed url, but the file will only be there after the browser actually pulled the url. My question was how to get to the location of the actual uploaded src file in `var/uploads` – Andreas Dec 10 '18 at 15:17
  • I don't get what you are trying to build. You need the original file to get the dimensions? – trickreich Dec 10 '18 at 16:05
  • jep, thats exactly what I need – Andreas Dec 11 '18 at 18:04