Note that there are some explanatory texts on larger screens.

plurals
  1. POPHP image server script returning broken image
    primarykey
    data
    text
    <p>I've been working on a website used to promote Tumblrs. I just created my first PHP Image Server script, so that we can save Tumblr Avatars and reduce those pesky Tumblr API calls.</p> <p>I have it working on the site now, however there is an odd glitch that's arising. When the page is opened, there's almost always 1 or 2 of the avatars that are showing up as broken images.</p> <p>Page with behavior: <a href="http://www.tumblrlink.com/" rel="nofollow">http://www.tumblrlink.com/</a></p> <p>I know it's not specific to a particular account, since refreshing the page will usually show a different set of images broken.</p> <p>This is the Image Server Script I built:</p> <pre><code>&lt;?php if (!isset($_GET['uri'])) exit(); $url = urldecode($_GET['uri']); // Check to make sure API URL is passed. if (strpos($url,'http://api.tumblr.com/') === FALSE) exit(); // Get the User's Tumblr "Short Name" $shortName = $url; $shortName = str_replace('http://api.tumblr.com/v2/blog/','',$shortName); $shortName = str_replace('/avatar/40','',$shortName); $avatarLoc = '../../media/avatars/' . $shortName . '.png'; // Save the Avatar to the server for use. if (!file_exists($avatarLoc)) { copy($url, $avatarLoc); } // Write out the contents of the Avatar Image. header("Content-Type: image/png"); header("Content-Length: " . filesize($avatarLoc)); readfile($avatarLoc); exit(); ?&gt; </code></pre> <p>Now, as you can see on the link, the images are saved and served successfully... but only 90% of the time.</p> <p>Is there some kind of programmed timing issue going on here, or could this be an issue with the server / environment? Any help would be appreciated.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload