Hi there, I have a template that displays a series of thumbnails taken from YouTube and Vimeo, using the Video Player module.
When the page loads there is a very consistent delay of around 10 seconds after it starts loading the page and before it starts loading all the resources. I had thought the delay was caused by the images loading from the external sites so I wrote a script to save them to the server. This has made almost no difference.
Here’s the offending code:
{exp:channel:entries channel="Portfolio" category="{segment_category_ids}"}
<?php
$imgOrig = "{work_video}{thumbnail_large}{/work_video}";
$imgName = basename($imgOrig);
if ($imgName == '0.jpg') {
$tokens = explode('/', $imgOrig);
$imgName = $tokens[sizeof($tokens)-2];
$imgName = $imgName.'.jpg';
}
$srcNew = $_SERVER['DOCUMENT_ROOT'] .'/images/thumbs/';
$imgNew = $srcNew . $imgName;
if (!file_exists($imgNew)) {
$ch = curl_init($imgOrig);
$fp = fopen($imgNew, 'wb');
curl_setopt($ch, CURLOPT_FILE, $fp);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_exec($ch);
curl_close($ch);
fclose($fp);
}
echo '<li sty1e="background-image: url({work_video}http://'.$_SERVER["SERVER_NAME"].'/images/thumbs/'.$imgName.'{/work_video});">';
?>
<a href="http://{url_title_path=">_ <hgroup>_ <h3>{title}</h3>_ <h4>{entry_date format="%F, %Y"}</h4><p>_ </hgroup>_ </a><br />
</li><br />
{/exp:channel:entries}As I said above my PHP hasn’t really made any difference to the timing and now I’m not sure how to figure out the problem.
Thanks in advance.