// We show here the excerpt, but not for these formats if ($post_format == '' || $post_format == 'gallery') { ?> <div class="entry-summary"> <?php echo quadro_excerpt(get_the_excerpt(), 30, '<span class="read-more">' . esc_html__('Read more', 'quadro') . '</span>'); ?> </div><!-- .entry-summary --> <?php } else { if ($post_format == 'quote') { echo '<div class="entry-summary">'; echo quadro_just_quote(get_the_content(), '', ''); echo '<a href="' . esc_url(get_the_permalink()) . '" class="readmore-link"><span class="read-more">' . esc_html__('Read more', 'quadro') . '</span></a>'; echo '</div>'; } elseif ($post_format == 'link' && is_array($the_link = quadro_getUrls(get_the_content())) && isset($the_link[0])) { // $the_link = quadro_getUrls(get_the_content())[0]; $the_link = $the_link[0]; $the_link_parsed = parse_url($the_link); echo '<div class="entry-summary">'; echo '<p class="the-link-url"><a href="' . esc_url($the_link) . '" title="' . $the_link . '">' . $the_link_parsed['host'] . '</a></p>'; echo '</div>'; } elseif ($post_format == 'audio' || $post_format == 'video') { echo '<div class="entry-summary">'; echo quadro_excerpt(get_the_excerpt(), 30, '<span class="read-more">' . esc_html__('Read more', 'quadro') . '</span>'); echo '</div>'; } elseif ($post_format == 'image') { // nothing here } elseif ($post_format == 'aside' || $post_format == 'status') { // Bring the full content for the other formats (aside & status between others) echo '<div class="entry-summary">';
/** * Retrieve a video screenshot URL from Vimeo or Youtube, from Content passed */ function quadro_video_screenshot_url($content) { // Bring URLs from content $urls = quadro_getUrls($content); // Filter URLs searching for Vimeo or YouTube videos foreach ($urls as $url) { if (strpos($url, 'vimeo') !== false) { // For Vimeo sscanf(parse_url($url, PHP_URL_PATH), '/%d', $video_id); $hash = unserialize(wp_remote_fopen('http://vimeo.com/api/v2/video/' . $video_id . '.php')); return esc_url($hash[0]['thumbnail_large']); // Skip all other URLs break; } elseif (strpos($url, 'youtube') !== false) { // For YouTube preg_match("#(?<=v=)[a-zA-Z0-9-]+(?=&)|(?<=v\\/)[^&\n]+(?=\\?)|(?<=v=)[^&\n]+|(?<=youtu.be/)[^&\n]+#", $url, $video_ids); $video_ids[0] = trim($video_ids[0]); return 'http://img.youtube.com/vi/' . $video_ids[0] . '/hqdefault.jpg'; // Skip all other URLs break; } } }