Support » Plugin: JSON API » 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&#8221; type=”text/javascript”></script>`
    Where the callback mobileSlider is a function

    function 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.

    http://wordpress.org/extend/plugins/json-api/

Viewing 1 replies (of 1 total)
  • Thread Starter harberg

    (@harberg)

    I figured this out (not sure if it is the best way) by adding a description in the media library to the images that I wanted to pull. Then I added an

    if(val.description == "foo") {
       (execute code)
    }

    If there is a better way I would love to hear it.

Viewing 1 replies (of 1 total)
  • The topic ‘Filtering out specific images with JSON api’ is closed to new replies.