ZenphotoCMS Forum
Thumbnail url for external link - Printable Version

+- ZenphotoCMS Forum (https://forum.zenphoto.org)
+-- Forum: Support (https://forum.zenphoto.org/forum-1.html)
+--- Forum: General support (https://forum.zenphoto.org/forum-4.html)
+--- Thread: Thumbnail url for external link (/thread-12116.html)



Thumbnail url for external link - bblackmoor - 2014-09-08

Thank you for making ZenPhoto. I am glad that I found it.

What is the best URL to use for an image thumbnail, such as one might use in a blog post? I have seen the two following types of URLs for thumbnails in ZenPhoto. Is one of these preferred over the other, or is there a third type of URL that I am not aware of?

https://www.blackgate.net/gallery/zp-core/i.php?a=Collections/Mugs_of_August&i=2011_August_02.jpg&s=595&cw=0&ch=0&q=85&wmk=%21&check=6570c91b09702b678700ccd6551fdd25276e6390

https://www.blackgate.net/gallery/cache/Collections/Mugs_of_August/2011_August_02_595.jpg

I have searched here for a solution, but it seems that most people want to prevent hotlinking, not make it easier.

Thank you.




Thumbnail url for external link - acrylian - 2014-09-08

The first links to the image processor that would be called anytime the page with the image is called. That would cause unneeded overhead.

So the second is the preferred one. To use it you need to make sure that the image is actually cached.




Thumbnail url for external link - bblackmoor - 2014-09-08

What if it is not cached? Surely there is a stable url that one can use for thumbnails, yes?




Thumbnail url for external link - acrylian - 2014-09-08

That url is stable but if the thumb is not cached there is no thumb at all.
http://www.zenphoto.org/news/caching




Thumbnail url for external link - bblackmoor - 2014-09-08

In which case, that is not useful. So the first link the best one to use, then.




Thumbnail url for external link - acrylian - 2014-09-08

No, it is not. Please read carefully how image resizing and caching works on Zenphoto. The first link will always run the image processor to create the thumb even if it is existsing already. If you have a lot of visitors and do this in lots of places you will create quite some unnecessary overhead on your server. Please be prepared to time outs especially if you are on shared hosting.




Thumbnail url for external link - bblackmoor - 2014-09-08

[deleted because I want to rephrase it]




Thumbnail url for external link - bblackmoor - 2014-09-08

I want to rephrase that, because I thought my first reply sounded argumentative.

What I want is a url that links to a thumbnail for an image. Typically, such a url would be a link to a script that returns the cached version (creating the cached version first, if it does not already exist).

It seemed reasonable to me to assume that Zenphoto would have this functionality, but it sounds like it may not.

Does Zenphoto have this functionality?




Thumbnail url for external link - acrylian - 2014-09-08

Well, the image processor does this, but it will also always check if it needs to cache -> overhead since there is file system operation involved that may not be necessary.

What you probably actually mean is an API for outside access. We don't exactly have one. The externalFeed plugin might be a workaround.




Thumbnail url for external link - sbillard - 2014-09-08

Use the image processor URI link. That one will always work. It will cache the thumbnail if it has not been cached. If it has already been cached it will serve the image from the cache.

Not quite as efficient as the browser directly fetching the cached image, but it will work whether or not there is a cached copy. The cache link will, of course, fail if you clear the cache or otherwise there is no cache copy of the thumbnail.




Thumbnail url for external link - bblackmoor - 2014-09-09

Thanks. I have a follow-up question. If I view all of the images first, that will create the cached thumbnails, yes? Are there any cases you know of when the cached images will expire and be deleted? Or, once they have been created, can I be reasonably sure that they will continue to exist at the same url?




Thumbnail url for external link - acrylian - 2014-09-09

The image cache does not expire by itself unless you clear it manually. If you change file sizes it will create new images for those sizes but not delete the old ones.




Thumbnail url for external link - bblackmoor - 2014-09-09

Ah, splendid. Then I can link to the cached thumbnails, as long as I make sure that the cached images exist first, which they will, as long as I have viewed the album in Zenphoto once before linking to the image.

Thank you for your patience. This has been very helpful.