Hey guys i have made an app for Piwigo gallery that help users to post photos from gallery into other software like Worpress or various forums types.
http://piwigo.org/ext/extension_view.php?eid=835I want to make something similar for Zenphoto.
But i have some problems
1) Current api seem unsupported by it's original autor. Both Piwigo and Menalto Gallery 3 have api that are officially supported and documented. Please support your Zenphoto REST api officially. They are some bugs some incomplete stuff, and there is no documentation for it.
2) Is possible to make the derivative file names not contain the size in pixels? Because having that number in the filename easily will broke any links to the thumbnail and websize in the future.
For example if a software like mine generate a bbcode like this for a forum software:
`[url=
http://site.com/cache/someuser/filename_595.jpg][img]http://site.com/cache/someuser/filename_150_cw150_ch150_thumb.jpg[/img][/url]`If the user change the size of the thumbnails or websize then the original link embeded in other software can be broken.
Piwigo dont have that size included in the filenames. They use something like this
filename-sq.jpg (square thumbnail)
filename-th.jpg (small thumbnail)
filename-me.jpg (websize thumbnail)
filename.jpg (original filename)
When user change the size option in his options panel he is not broking the past links.
Comments
I have plans to create an more complete official (read only) REST API following that principle for the next big release. That release sadly will take some time as time is sadly an issue.
For now you would have to use RSS. There is an probably rather inconvenient externalRSS plugin you could use for now.
2) No, those file names are the names of the cached files and they tell Zenphoto that it does not need to process this specific sizes again. That cannot be changed.
Piwigo and WP do use a fixed set of image sizes they pregenerated. But Zenphoto does not do this and leaves the freedom to use any size in any number to theme and plugins. So there are no fixed file names possible to link to. To change the size without using Zenphoto itself you woul have to call the image processor (see zp-core/i.php): But you really don't want to allow that to everyone from the outside as that surely can overload your server.
1) nice to hear that. i already builded my zenphoto2img app one week ago based on "tacocat-gallery-zenphoto-rest-api", but this app is more primitive compared with my piwigo app. because with the current zenphoto REST api you get less info about images and albums. also is very hard to build an album tree because you cannot get that from a single api request, so i'm building only the main albums first making one request, then using ajax i'm building the subalbums for the selected album.
also got the same bug like this guy reported 9 months ago and the autor didn't fix the problem
https://github.com/deanmoses/tacocat-gallery-zenphoto-rest-api/issues/4
2) then this is bad if the filename must contain the image size in pixels. this will make zenphoto links very brokeable when integrating zenphoto in any other type of software.
2) Well, it is how Zenphoto works and this will not be changed. Those cached images are not fixed, the cache may be deleted so it is not recommended to link to that directly with fixed links. Instead use the image processor if you are not sure. That will either create the cache image or serve existing ones. Which actually the api would do before returning anything.
can you give an example how "i.php" query parameter would look like to be equivalent with this kind of links?
websize:
http://site.com/cache/someuser/filename_595.jpg = http://site.com/i.php?...
thumb:
http://site.com/cache/someuser/filename_150_cw150_ch150_thumb.jpg = http://site.com/i.php?...
But in the meantime I fixed up mine.
1) The bugs people filed issues for are fixed.
2) You get the whole tree of albums all the way down; it doesn't stop at one level.
3) It still doesn't get as many fields as you want, eliz82. If you have specific fields I can add them. Anybody know if there's a way to iterate over all fields?
It's at a new location:
https://github.com/deanmoses/zenphoto-json-rest-api
The "deep" parameter seems nice, allowing me to fix one of the problems.
I will take a look at the api new version when I will have some free time.
@acrylian
By "file's docblock" you mean looking at the "i.php" source code, or there is some sort of documentation for zenphoto?
I know this topic is quite old, but wanted to add anyway in case someone has the same requirements.
You could use a
.htaccess
rewrite rule for those pre-defined image sizes. Something like this (untested):This should match all file requests ending in
-sq.jpg
and redirect those requests to the same filename but ending in_150_cw150_ch150.jpg
instead.Once you decide to go to 175 px sized thumbnails (for example) you just change the rewrite rule and you're done (caching aside as noted above).
You should really not rely on someething like this as just a theme of plugin may not use that size. The cached file names contain the size parameters for a reason. Zenphoto does not have fixed sizes like Piwigo or other CMS have, themes and plugins can use whatever they want whenever they want.