Example #1
0
    function vw_the_post_thumbnail($size = VW_CONST_THUMBNAIL_SIZE_SINGLE_POST_CLASSIC, $attr = '')
    {
        $featured_image_id = vw_get_featured_image_id();
        if (empty($featured_image_id)) {
            return;
        }
        $full_image_url = wp_get_attachment_image_src($featured_image_id, 'full');
        ?>

		<a class="swipebox" href="<?php 
        echo $full_image_url[0];
        ?>
" title="<?php 
        the_title_attribute();
        ?>
" rel="bookmark">
			<?php 
        echo wp_get_attachment_image($featured_image_id, $size, false, array('class' => "attachment-{$size} wp-post-image", 'itemprop' => 'image'));
        ?>

		</a>
		<?php 
        $image_caption = get_post($featured_image_id)->post_excerpt;
        if (!empty($image_caption)) {
            printf('<div class="vw-featured-image-caption-wrapper"><div class="vw-featured-image-caption"><i class="icon-entypo-camera"></i> %s</div></div>', $image_caption);
        }
    }
Example #2
0
    function vw_enqueue_scripts_backstretch()
    {
        if (function_exists('is_product') && is_product()) {
            return;
        }
        if (have_posts()) {
            the_post();
            global $post;
            $image_urls = array();
            $image_captions = array();
            if (is_single() && has_post_format('gallery')) {
                $attachments = get_post_meta(get_the_ID(), 'vw_post_format_gallery_images', false);
                foreach ($attachments as $attachment_ID) {
                    $full_image_url = wp_get_attachment_image_src($attachment_ID, VW_CONST_THUMBNAIL_SIZE_PAGE_TILE_BACKGROUND);
                    if ($full_image_url) {
                        $image_urls[] = $full_image_url[0];
                        $image_caption = get_post($attachment_ID)->post_excerpt;
                        if (!empty($image_caption)) {
                            $image_captions[] = sprintf('<div class="vw-featured-image-caption hidden"><i class="icon-entypo-camera"></i> %s</div>', $image_caption);
                        }
                    }
                }
            }
            if (is_single() && has_post_thumbnail() && empty($image_urls) || is_page()) {
                $featured_image_id = vw_get_featured_image_id($post->ID);
                $full_image_url = wp_get_attachment_image_src($featured_image_id, VW_CONST_THUMBNAIL_SIZE_PAGE_TILE_BACKGROUND);
                if ($full_image_url) {
                    $image_urls[] = $full_image_url[0];
                }
                $image_caption = get_post($featured_image_id)->post_excerpt;
                if (!empty($image_caption)) {
                    $image_captions[] = sprintf('<div class="vw-featured-image-caption hidden"><i class="icon-entypo-camera"></i> %s</div>', $image_caption);
                }
            }
            if (is_category()) {
                $image_id = vw_get_category_option(vw_get_archive_category_id(), 'category_background_image');
                $full_image_url = wp_get_attachment_image_src($image_id, VW_CONST_THUMBNAIL_SIZE_PAGE_TILE_BACKGROUND);
                if ($full_image_url) {
                    $image_urls[] = $full_image_url[0];
                }
            }
            if (function_exists('is_product_category') && is_product_category()) {
                global $wp_query;
                $cat_obj = $wp_query->get_queried_object();
                $image_id = vw_get_product_category_option($cat_obj->term_id, 'category_background_image');
                $full_image_url = wp_get_attachment_image_src($image_id, VW_CONST_THUMBNAIL_SIZE_PAGE_TILE_BACKGROUND);
                if ($full_image_url) {
                    $image_urls[] = $full_image_url[0];
                }
            }
            if (!empty($image_urls)) {
                ?>

				<script id="vw-backstretch-image-captions-template" type="text/template">
					<div class="vw-page-title-image-captions .vw-featured-image-caption-wrapper">
						<?php 
                echo implode('', $image_captions);
                ?>
					</div>
				</script>

				<script type='text/javascript'>
					"use strict";
					if ( jQuery.backstretch ) {
						var $target = jQuery( '.vw-page-title-wrapper' );
						$target.backstretch(
							['<?php 
                echo implode("','", $image_urls);
                ?>
'], {
								fade: <?php 
                echo VW_CONST_BACKSTRETCH_OPT_FADE;
                ?>
,
								centeredY: <?php 
                echo VW_CONST_BACKSTRETCH_OPT_CENTEREDY;
                ?>
,
								centeredX: <?php 
                echo VW_CONST_BACKSTRETCH_OPT_CENTEREDX;
                ?>
,
								duration: <?php 
                echo VW_CONST_BACKSTRETCH_OPT_DURATION;
                ?>
,
							}
						).addClass( 'vw-backstretch vw-has-background' );

						var $image_captions = jQuery( '#vw-backstretch-image-captions-template' ).html();
						$target.find( '.vw-page-title-wrapper-inner' ).before( $image_captions );

						jQuery( '.vw-gallery-direction-button.vw-gallery-direction-next' ).click( function() {
							$target.backstretch("next");
						} );

						jQuery( '.vw-gallery-direction-button.vw-gallery-direction-prev' ).click( function() {
							$target.backstretch("prev");
						} );

						jQuery(window).on("backstretch.after", function (e, instance, index) {
							jQuery( '.vw-page-title-image-captions .vw-featured-image-caption' )
								.addClass( 'hidden' )
								.eq( index ).removeClass( 'hidden' );
						});
					}
				</script>

			<?php 
            }
            rewind_posts();
        }
    }