To clarify the title question, I have code such as:
<img src='gallery/main.php?g2_view=core.DownloadItem&g2_itemId=8161&g2_serialNumber=2'>
with the file actually residing in the file system under my webroot. Is there any way in PHP to retrieve the images real path being served such as:
<img src='images/gallery/album1/file1.jpg'>
Eg someFunction(longURL) ==> images/gallery/album1/file1.jpg
Thank you,
Posts: 4338
It's actually not clear what you're asking. Images stored in Gallery should *never* be accessed via the file-system path, other than by Gallery itself - the g2data directory (including the albums subdirectory) is essentially private to Gallery only.
There are ways to obtain the correct url (either like ...main.php?g2_itemId=.... or if you urlrewrite then ...gallery2/v/.... ) to put in an img tag, given the itemId. Is that what you're asking for?
Posts: 2
Why should images *never** be accessed this way? This is the root of my question. To give a bit of context, I am trying to fetch the real URL of an image inside of gallery, and pass it to a thumbnail-ing script.
I guess my real question is really, how can I retrieve an images full URL based on its g2_itemId?
Also, why is the path to the image stored in chunks in the Filesystem entity table?
Thanks so much for the help,
Posts: 4338
That's easy: http:// .... main.php?g2_view=core.DownloadItem&g2_itemId=xxxx
It's when you want to recover the thumbnail, or a resize, and you only have the original's id that things get interesting.
the g2data directory is 100% recommended to be *outside* the web root of your site, and Gallery serves all images itself. So other than the Gallery-based url if you follow recommended practice there's *no* other "full URL" based on a file-system path.
Since it's stored in a private Gallery-only directory, it's not really important how Gallery stores the path, or whether or not it's convenient for outside scripts.
Basically Gallery2 wasn't written to be a repository for images to be accessed by other php-based scripts, it was written to be a web-based image library; so to use it for other purposes involves jumping through hoops.
Posts: 14
I am also trying to get the full URL of an item. I am having trouble streaming videos because they stop at about 15MB. If they're accessed directly, I have no trouble. I could send the full URL to the Flash Video module to enable larger videos to download completely.
http://gallery.menalto.com/node/41471#comment-307411