php - Instagram API non-square images not being returned for $data->images->standard_resolution -
api url: api.instagram.com/v1/users/self/media/recent/?access_token=kablenghe
i'm trying figure out way take image url standard_resolution image, instagram keeps serving cropped images.
cropped image url:
scontent.cdninstagram.com/t51.2885-15/s480x480/e35/c236.0.607.607/14474173_314142642294695_7071485231332589568_n.jpg?ig_cache_key=blah
non-cropped image url:
scontent.cdninstagram.com/t51.2885-15/s480x480/e35/14474173_314142642294695_7071485231332589568_n.jpg?ig_cache_key=splerf
so need removed portion: "/c236.0.607.607" instagram uses position , size image crop. several people asking question, i'm not finding who's found answer irritating little instagram api issue cropped images , non-square media.
ok, think may have figured out. here's have:
// standard_resolution url instagram api response $full_res_cropped = $item['images']['standard_resolution']['url']; // regex pattern $pattern = '#\/c+(.\d[0-9]+\.\d.)+(\d)#'; // replace empty string $replacement = ''; // preg_replace $full_res = preg_replace($pattern, $replacement, $full_res_cropped); so results are:
// $full_res_cropped cropped image url (original) scontent.cdninstagram.com/t51.2885-15/s480x480/e35/c236.0.607.607/14474173_314142642294695_7071485231332589568_n.jpg?ig_cache_key=flarg // $full_res resized, non-cropped url (fixed) scontent.cdninstagram.com/t51.2885-15/s480x480/e35/14474173_314142642294695_7071485231332589568_n.jpg?ig_cache_key=flarg this work until instagram changes way crop , position images , change url structure, until then. cool, guess.
hope helps else having similar issue!
Comments
Post a Comment