Tagged: 

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #415434

    Hi!

    I have installed the enfold child theme and it works fine.

    Now I wanted to add an automatic thumbnail image for videos in post masonries. So I added a line in function prepare_loop_from_entries() in /config-templatebuilder/avia-shortcodes/masonry_entries.php. This works fine.

    Now I want to make the whole hack via the child theme so it is update proof. But I can’t figure out how.

    1. I created the filestructure /config-templatebuilder/avia-shortcodes/ in the child theme folder an copied masonry_entries.php therein. But nothing happens – the original version keeps showing.
    2. I copied the function prepare_loop_from_entries() in the child themes function.php – with no success. The original version is taken.

    What do I do wrong?

    Regards,
    Rolf

    • This topic was modified 9 years, 8 months ago by mlkg.
    #415813
    #416443

    Great, this works!

    By the way, the code I changed/added is this:

    masonry_entries.php, from line 770:

    							case 'video' :
    								if(!$this->loop[$key]['thumb_ID']) 
    								{
    									preg_match_all('#\bhttps?://[^\s()<>]+(?:\([\w\d]+\)|([^[:punct:]\s]|/))#', $entry->post_content, $match);
    									foreach($match[0] as $test_url){
    										if($this->loop[$key]['video_image_url']=video_get_image_url ($test_url))
    											break;
    									}
    									if($this->loop[$key]['video_image_url']=="")
    											$this->loop[$key]['text_before'] = av_icon_display($post_format);
    								}
    								else
    									$this->loop[$key]['text_before'] = av_icon_display($post_format, 'av-masonry-media');
    								break;

    …and line 863:

    				//get attachment data
    				$this->loop[$key]['attachment'] = !empty($this->loop[$key]['thumb_ID']) ? wp_get_attachment_image_src($this->loop[$key]['thumb_ID'], $img_size) : array($this->loop[$key]['video_image_url']);

    and in functions.php this function:

    // Video-URL
    function video_get_image_url($url,$size="thumbnail_large"){
    	$image_src = parse_url($url);
    	if($image_src['host'] == 'www.vimeo.com' || $image_src['host'] == 'vimeo.com' || $image_src['host'] == 'player.vimeo.com'){
    		parse_str($image_src['query'], $query);
    		if(isset($query['clip_id']) && $query['clip_id'] != ""){
    			$id = $query['clip_id'];
    		} else {
    			$path = explode("/",$image_src['path']);
    			$id = $path[(count($path)-1)];
    		}
    		if(function_exists('curl_init')){;
    			$ch = curl_init();
    			curl_setopt($ch, CURLOPT_URL, "http://vimeo.com/api/v2/video/$id.php");
    			curl_setopt($ch, CURLOPT_HEADER, 0);
    			curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    			curl_setopt($ch, CURLOPT_TIMEOUT, 10);
    			$output = unserialize(curl_exec($ch));
    			$output = $output[0][$size];
    			curl_close($ch);
    			return $output;	
    		}
    	}
    	else if($image_src['host'] == 'www.youtube.com' || $image_src['host'] == 'youtube.com'){
    		parse_str($image_src['query'], $query);
    		if(isset($query['v']) && $query['v'] != ""){
    			$id = $query['v'];
    		} else {
    			$path = explode("/",$image_src['path']);
    			$id = $path[count($path)-1];
    		}
    		if($size=="thumbnail_large")
    			return "http://img.youtube.com/vi/".$id."/0.jpg";				
    		else
    			return "http://img.youtube.com/vi/".$id."/default.jpg";				
    	} else{
    		return false;
    	}
    }
    

    Voilá – now every post content of type “video” in the masonry automagically displays the cover image of the first video of the post instead of only the video icon. Wouldn’t this feature be nice for a future enfold update? :-)

    #416696

    Hey!

    Feel free to request it here as a new feature :)

    Best regards, 
    Josue

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.