From 3ea9610796770bb2ba54d3c8c0f465a22eb9e3c8 Mon Sep 17 00:00:00 2001 From: Sem Date: Thu, 7 Nov 2013 06:01:06 +0100 Subject: Making video thumbnails faster (thanks to ura soul). --- start.php | 37 +++++++++++++++++++++++++------------ 1 file changed, 25 insertions(+), 12 deletions(-) (limited to 'start.php') diff --git a/start.php b/start.php index 2094ffacc..6f94b97d0 100644 --- a/start.php +++ b/start.php @@ -270,22 +270,35 @@ function videolist_embed_get_items($hook, $type, $value, $params) { * @return string Relative URL */ function videolist_icon_url_override($hook, $type, $returnvalue, $params) { - $videolist_item = $params['entity']; - /* @var ElggObject $videolist_item */ - $size = $params['size']; - if($videolist_item->getSubtype() != 'videolist_item'){ - return $returnvalue; - } - - // tiny thumbnails are too small to be useful, so give a generic video icon - if ($size != 'tiny' && isset($videolist_item->thumbnail)) { - return elgg_get_site_url() . "mod/videolist/thumbnail.php?guid=" . $videolist_item->guid; + // if someone already set this, quit + if ($return_value) { + return null; } - if (in_array($size, array('tiny', 'small', 'medium'))){ - return "mod/videolist/graphics/videolist_icon_{$size}.png"; + $videolist_item = $params['entity']; + $size = $params['size']; + + if (!elgg_instanceof($videolist_item, 'object', 'videolist_item')) { + return null; } + + // tiny thumbnails are too small to be useful, so give a generic video icon + try { + if ($size != 'tiny' && isset($videolist_item->thumbnail)) { + $owner = $videolist_item->getOwnerEntity(); + $owner_guid = $owner->getGUID(); + $join_date = $owner->getTimeCreated(); + return "mod/videolist/thumbnail.php?joindate=$join_date&guid={$videolist_item->guid}&owner_guid=$owner_guid&size=$size"; + } + } catch (InvalidParameterException $e) { + elgg_log("Unable to get videolist icon for video with GUID {$videolist_item->guid}", 'ERROR'); + return "mod/videolist/graphics/videolist_icon_{$size}.png"; + } + if (in_array($size, array('tiny', 'small', 'medium'))){ + return "mod/videolist/graphics/videolist_icon_{$size}.png"; + } + return null; } /** -- cgit v1.2.3