Filtering out specific images with JSON api
-
Hello everyone,
I am currently using the json api to take information from a page and display it onto a jQuery mobile page. I have created extra meta boxes on one of my page templates so that the client can upload photos to be used in specific spots on the pages. There are a eight meta boxes that all will be have a different photo. When I call the json object from that page using`
<script src=”http://mysite.com/the-collections/?json=1&callback=mobileSlider” type=”text/javascript”></script>`
Where the callback mobileSlider is a functionfunction mobileSlider(data) { var output = '<ul class="slides">'; $.each(data.page.attachments, function(key, val) { output += '<li>'; //output += data.page.title; output += '<img src=" ' + val.images.full.url + ' " />'; output += '</li>'; });// go through each image output += '</ul>'; $('#mobileSliderContainer').html(output); )};
This will give me all of the images(8 total) as attachments, but I only want to be call half of the images. How can I determine which images to use? I can’t use specific ID’s because the images will be changing overtime. I tried adding a description to the images that I wanted in the media library, but couldn’t figure out how to just filter out the images that had a description.
Any help and examples would be really helpful. I also want to make sure it was clear that I am not pulling images from a post, but from a page.
Thanks for your help.
- The topic ‘Filtering out specific images with JSON api’ is closed to new replies.