/** * Filter Content Output for video */ function mp_stacks_brick_content_output_video($default_content_output, $mp_stacks_content_type, $post_id) { //If this stack content type is set to be an image if ($mp_stacks_content_type == 'video') { //Set default value for $content_output to NULL $content_output = NULL; //Get video URL $brick_video = get_post_meta($post_id, 'brick_video_url', true); //Get video max width $brick_video_max_width = get_post_meta($post_id, 'brick_video_max_width', true); $brick_video_max_width = !empty($brick_video_max_width) ? $brick_video_max_width : NULL; //Content output if (!empty($brick_video)) { $args = array('min_width' => NULL, 'max_width' => $brick_video_max_width, 'iframe_css_id' => NULL, 'iframe_css_class' => NULL); $content_output .= '<div class="mp-stacks-video">' . mp_core_oembed_get($brick_video, $args) . '</div>'; } //Return return $content_output; } else { //Return return $default_content_output; } }
/** * Wrap a url in it's appropriate HTML5 tag for displaying * * @access public * @since 1.0.0 * @param $array array The array we want to sort. * @param $key String The key we wish to sort by (eg create a 'date' key in sub-arrays and pass the word 'date' to sort by that number. * @return $order SORT_DESC or SORT_ASC */ function mp_core_wrap_media_url_in_html_tag($url, $args = array()) { $defaults = array('autoplay_videos' => false); $args = wp_parse_args($args, $defaults); $autoplay = $args['autoplay_videos'] ? 'autoplay' : NULL; $info = pathinfo($url); $basename = isset($info['basename']) ? $info['basename'] : NULL; $ext = isset($info['extension']) ? $info['extension'] : NULL; if ($ext == 'jpg' || $ext == 'png') { $return_html = '<img src="' . $url . '" style="max-width:100%;" />'; } else { if ($ext == 'mp4') { $return_html = '<video controls ' . $autoplay . ' name="media" style="max-width:100%;"> <source src="' . $url . '" type="video/mp4"> </video>'; } else { return mp_core_oembed_get($url); } } return $return_html; }