![]() |
|
image_instantiate pulling data from wrong image - Printable Version +- ZenphotoCMS Forum (https://forum.zenphoto.org) +-- Forum: Support (https://forum.zenphoto.org/forum-1.html) +--- Forum: Plugins (https://forum.zenphoto.org/forum-6.html) +--- Thread: image_instantiate pulling data from wrong image (/thread-12094.html) |
image_instantiate pulling data from wrong image - sanderzp - 2014-08-31 Hey all I'm trying to build a simple plugin to do some stuff off the tags on an image. I started with the no_show example (I know its not supported, but it seemed like a decent starting place for what I wanted to do). Anyway, I have a plugin that basically looks like:
";
} My issue is that, in an album with 2 images, when I specifically open the second image, it has the filename (and other metadata) for the first image in the album. E.g. if I have an album "foo" with two files: If I open up the second image at I'm sure this has something to do with my misunderstanding with how image_instantiate works, but can anyone point me in the right direction? Thanks image_instantiate pulling data from wrong image - sanderzp - 2014-08-31 OK, I don't think I understand how image_instantiate is supposed to work... Digging around in source code, I found some references to $_zp_current_image. So I tried that:
";
} However, when looking at an album view with the two images in it, it shows an empty list for the first image, and the image details for the first image by the second image. I would have expected it to show the correct details by each image, or nothing... Meanwhile, my original method using imageObj->getTags() instead of $_zp_current_image->getTags() showed the correct details next to each image in the album view, but the totally wrong details in the image detail view. How can I reliably get a handle on the tags for each image regardless of whether I'm looking at an album view or an image detail view? Thanks image_instantiate pulling data from wrong image - fretzl - 2014-08-31 Why don't you just put something like this in the [i]functions.php[/i] file (in your theme folder)
image_instantiate pulling data from wrong image - acrylian - 2014-08-31 Fretzl's way is how to do it. The filter you used is something different and invoke when the image object is setup. That's a bit something different. If you want to show the data on the album view, you need to place fretzl's function within the You can all do using the object model directly (see the tutorial) but the filter is not needed in any case. image_instantiate pulling data from wrong image - sanderzp - 2014-08-31 Well... Because I eventually want to filter out images based on tag data, and I didn't think that's something that should be done from the theme, but rather from a plugin. I want the filtering to be done regardless of theme. This was just the first step - I'm trying to figure out how to loop through the items in an album or an item detail page and get the tags, and then filter them out of all results. I actually did hack something up that works, although setting I guess let me be more clear - I want to exclude items from search results, album views and item detail views based on certain tag values. Possible? Am I so far off the track of how to go about this? Thanks image_instantiate pulling data from wrong image - acrylian - 2014-08-31
The right filter should be
image_instantiate pulling data from wrong image - sanderzp - 2014-09-01 Awesome, thanks acrylian - I'll give that a whirl. Thanks image_instantiate pulling data from wrong image - sanderzp - 2014-09-01 hm... Sorry, two follow up questions... 1 - image_filter appears to take a list of filenames from the file system rather than a list of image objects (that I can get the tags from). Is the right way to turn the filename into an image object: 2 - It looks like image_filter gets called twice? E.g.: function some_method ($image_array) {
} |