Skip to content Skip to sidebar Skip to footer

Instagram Photos Array With All Photos To Array Of Selected Photos

I'm trying to set up my Instagram API site so that users can select photos I am able to save the data in an database and Display the photos but not able to make photos selectable

Solution 1:

you cannot make the images "selectable" with php, you need to do that with some javascript and css styles

img.selected {
  border:solid 1px green;
}

Then with some javascript, you can find all the images with document.images or document.getElementsByTagName('img'). It would be best if you gave them all a class to select from document.getElementsByClassName('insta-photos') where the images class attribute is insta-photos

...once you have the list of images, you can add some event handling for the "selection", all you have to do is unselect all the other images (ie remove the selected class from all of the images) and select the current one by updating its css class to "selected"

Ultimately with php, you could put a link around each image that did roundtrips from the client and the server, displaying the "selected" image. you can pass it in as a url parameter..

$selected = params['selected'];

// Display results
foreach ($popular->data as $data)
{
  $css = "insta-photo"
  if ($selected == $data) { $css = "insta-photo selected" }
  echo "<a href=\"{$data->images->thumbnail->url}\" class=\"{$css}\">"
  echo "  <img src=\"{$data->images->thumbnail->url}\">"
  echo "<\a>"
}                                       

Post a Comment for "Instagram Photos Array With All Photos To Array Of Selected Photos"