Just checking to see if there is an easy way right now to get all the images with a certain tag as part of a theme I am creating. Thinking this would be something like getImagesWithTag("tag"), but haven't seen any way in the docs I can reproduce that. Just wanted to see if this was already done before I start writing my own custom function. Any guidance on a custom function would be appreciated as well. Thanks!
Get all images with tag(5 posts)
I have done a tag search using
$search->searchFieldsAndTags(Array("JB001"), "images", "id", "desc") and am getting a couple of image results, but now I want to be able to print thumbnails of those results. I have been going through the documentation and the nearest thing I can find is newImage(). Is that the correct way to get the image object so that I can get the image thumbnail? Any code would be appreciated.
To get an image object, you need the album object first as well. Please look at the object model tutorial. You will need to understand that if you want to display the results without performing an actual search on the search page. The easiest might be to either create a search based on this tag and create a dynamic album. Info on those on the user guide.
Actually (fortunately) when you do a $search->getImages() it will return an array of "image names" but the elements of this array are themselves arrays and contain the album and image names. I do not remember exactly the release this was introduced, but at least for 1.4.1 you can just use
$image=newImage(NULL, $searchresult);to instantiate the image. (
$searchresultis one element of the array returned.)
You must log in to post.