Re-Request: Make link of thumbnail instead of playing onclick
-
Hello,
A while ago I implemented a solution you provided to another users request, which was making a link of the preview thumbnail instead of playing on click.
I’m referring to this thread:
After all the major changes proceeding youtubes drop of v2 api, I’m no longer able to get this to work. I believe it’s due to a change in the api.php file, but I could be wrong.
To make a long story short, I would still like to be able to have the thumbnails link rather than playing onclick.
Is this still possible?
The following is the code that used to work, but no longer does:
/* Load the "Related YouTube Videos" API class if it does not exist yet. */ if( !class_exists( 'RelatedYouTubeVideos_API' ) ) { $file = str_replace( '/', DIRECTORY_SEPARATOR, ABSPATH ) . 'lib' . DIRECTORY_SEPARATOR . 'RelatedYouTubeVidoes' . DIRECTORY_SEPARATOR . 'API.php'; if( file_exists( $file ) ) { include_once $file; } } /* Only continue if the API class could be loaded properly. */ if( class_exists( 'RelatedYouTubeVideos_API' ) ) { $RytvAPI = new RelatedYouTubeVideos_API(); /* Do your configuration */ $data = $RytvAPI->validateConfiguration( array( 'relation' => 'postTitle', 'max' => '3', 'width' => 150, 'height' => 150 ) ); /* Search YouTube. */ $results = $RytvAPI->searchYouTube( $data ); /* Create your very own custom HTML */ if( !empty( $results ) ) { foreach( $results as $video ) { // Try detecting the YouTube Video ID $videoID = ( preg_match( '#\?v=([^&]*)&#i', $video->link['href'], $match ) && isset( $match[1] ) ) ? (string) $match[1] : ''; echo '<a href="' . $video->link['href'] . '"><img src="https://img.youtube.com/vi/' . $videoID . '/0.jpg" alt="" width="150" height="150" /></a>' . "\n"; } } }
I’m using your latest release of Related Youtube Videos by the way. And, this may be obvious, but I’m trying to hard code this functionality in a theme I’m using. I appreciate any help in advance.
Thanks, Dana
https://www.ads-software.com/plugins/related-youtube-videos/
- The topic ‘Re-Request: Make link of thumbnail instead of playing onclick’ is closed to new replies.