Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if ( ! function_exists( 'kleo_get_post_media' ) ) {
- /**
- * Return post media by format
- *
- * @param $post_format
- * @param $options
- *
- * @return string
- *
- * @since 3.0
- */
- function kleo_get_post_media( $post_format = 'standard', $options = array() ) {
- global $kleo_config;
- if ( isset( $options['icons'] ) && $options['icons'] ) {
- $icons = true;
- } else {
- $icons = false;
- }
- if ( isset( $options['media_width'] ) && isset( $options['media_height'] ) ) {
- $media_width = $options['media_width'];
- $media_height = $options['media_height'];
- } else {
- $media_width = $kleo_config['post_gallery_img_width'];
- $media_height = $kleo_config['post_gallery_img_height'];
- }
- $output = '';
- switch ( $post_format ) {
- case 'video':
- //oEmbed video
- $video = get_cfield( 'embed' );
- // video bg self hosted
- $bg_video_args = array();
- $k_video = '';
- if ( get_cfield( 'video_mp4' ) ) {
- $bg_video_args['mp4'] = get_cfield( 'video_mp4' );
- }
- if ( get_cfield( 'video_ogv' ) ) {
- $bg_video_args['ogv'] = get_cfield( 'video_ogv' );
- }
- if ( get_cfield( 'video_webm' ) ) {
- $bg_video_args['webm'] = get_cfield( 'video_webm' );
- }
- if ( ! empty( $bg_video_args ) ) {
- $attr_strings = array(
- 'preload="none"'
- );
- if ( get_cfield( 'video_poster' ) ) {
- $attr_strings[] = 'poster="' . get_cfield( 'video_poster' ) . '"';
- }
- $k_video .= '<div class="kleo-video-wrap"><video ' . join( ' ', $attr_strings ) . ' controls="controls" class="kleo-video" style="width: 100%; height: 100%;">';
- $source = '<source type="%s" src="%s" />';
- foreach ( $bg_video_args as $video_type => $video_src ) {
- $video_type = wp_check_filetype( $video_src, wp_get_mime_types() );
- $k_video .= sprintf( $source, $video_type['type'], esc_url( $video_src ) );
- }
- $k_video .= '</video></div>';
- $output .= $k_video;
- } // oEmbed
- elseif ( ! empty( $video ) ) {
- global $wp_embed;
- $output .= apply_filters( 'kleo_oembed_video', $video );
- }
- break;
- case 'audio':
- $audio = get_cfield( 'audio' );
- if ( ! empty( $audio ) ) {
- $output .=
- '<div class="post-audio">' .
- '<audio preload="none" class="kleo-audio" id="audio_' . get_the_ID() . '" style="width:100%;" src="' . $audio . '"></audio>' .
- '</div>';
- }
- break;
- case 'gallery':
- $slides = get_cfield( 'slider' );
- $output .= '<div class="kleo-banner-slider">'
- . '<div class="kleo-banner-items" >';
- if ( $slides ) {
- foreach ( $slides as $slide ) {
- if ( $slide ) {
- $image = aq_resize( $slide, $media_width, $media_height, true, true, true );
- //small hack for non-hosted images
- if ( ! $image ) {
- $image = $slide;
- }
- $output .= '<article>
- <a href="' . $slide . '" data-rel="modalPhoto[inner-gallery]">
- <img src="' . $image . '" alt="' . get_the_title() . '">'
- . kleo_get_img_overlay()
- . '</a>
- </article>';
- }
- }
- }
- $output .= '</div>'
- . '<a href="#" class="kleo-banner-prev"><i class="icon-angle-left"></i></a>'
- . '<a href="#" class="kleo-banner-next"><i class="icon-angle-right"></i></a>'
- . '<div class="kleo-banner-features-pager carousel-pager"></div>'
- . '</div>';
- break;
- case 'aside':
- if ( $icons ) {
- $output .= '<div class="post-format-icon"><i class="icon icon-doc"></i></div>';
- }
- break;
- case 'link':
- if ( $icons ) {
- $output .= '<div class="post-format-icon"><i class="icon icon-link"></i></div>';
- }
- break;
- case 'quote':
- if ( $icons ) {
- $output .= '<div class="post-format-icon"><i class="icon icon-quote-right"></i></div>';
- }
- break;
- case 'image':
- default:
- if ( kleo_get_post_thumbnail_url() != '' ) {
- $output .= '<div class="post-image 9999">';
- $img_url = kleo_get_post_thumbnail_url();
- //$image = aq_resize( $img_url, $media_width, $media_height, true, true, true );
- if ( ! $image ) {
- $image = $img_url;
- }
- $output .= '<a href="' . get_permalink() . '" class="element-wrap">'
- . '<img src="' . $image . '" alt="' . get_the_title() . '">'
- . kleo_get_img_overlay()
- . '</a>';
- $output .= '</div><!--end post-image-->';
- } elseif ( $icons ) {
- $post_icon = $post_format == 'image' ? 'picture' : 'doc';
- $output .= '<div class="post-format-icon"><i class="icon icon-' . $post_icon . '"></i></div>';
- }
- break;
- }
- return $output;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement