$attachment_count = count($product->get_gallery_attachment_ids()); $loop = 0; $columns = apply_filters('woocommerce_product_thumbnails_columns', 3); foreach ($attachment_ids as $attachment_id) { $classes = array('zoom'); if ($loop == 0 || $loop % $columns == 0) { $classes[] = 'first'; } if (($loop + 1) % $columns == 0) { $classes[] = 'last'; } $image_link = wp_get_attachment_url($attachment_id); if (!$image_link) { continue; } $image = rt_vt_resize('', $image_link, 460, 1000, false); $image_title = esc_attr(get_the_title($attachment_id)); $image_class = esc_attr(implode(' ', $classes)); printf('<div class="item"><a href="%1$s" class="%2$s" title="%3$s" data-rel="prettyPhoto[product-gallery]"><img src="%4$s" alt="%3$s"></a></div>', $image_link, $image_class, $image_title, $image["url"]); $loop++; } } else { echo apply_filters('woocommerce_single_product_image_html', sprintf('<li><img src="%s" alt="Placeholder" /></li>', woocommerce_placeholder_img_src()), $post->ID); } ?> </div></section></section></div> <?php //js script to run printf('
<?php # # rt-theme # post content for standart post types in listing pages # global $rt_list_style, $more, $rt_global_post_values; //extract global values extract($rt_global_post_values); if ($audio_usage_listing == "only_featured_image") { // Create thumbnail image $thumbnail_image_output = !empty($featured_image_id) ? get_resized_image_output(array("image_url" => "", "image_id" => $featured_image_id, "w" => $featured_image_width, "h" => $featured_image_height, "crop" => $crop)) : ""; // Tiny image thumbnail for lightbox gallery feature $lightbox_thumbnail = !empty($featured_image_id) ? rt_vt_resize($featured_image_id, "", 75, 50, true) : rt_vt_resize($featured_image_id, "", 75, 50, true); $lightbox_thumbnail = is_array($lightbox_thumbnail) ? $lightbox_thumbnail["url"] : ""; } else { $thumbnail_image_output = ""; } ?> <!-- blog box--> <article class="blog_list loop" id="post-<?php the_ID(); ?> "> <?php if ($rt_list_style == "style1") { ?> <section class="first_section">
/** * Get html output of a resized image * @param array $atts * @return html */ function get_resized_image_output($atts = array()) { //defaults extract(shortcode_atts(array("image_url" => "", "image_id" => "", "w" => "", "h" => "", "crop" => false, "class" => ""), $atts)); if (empty($image_id) && empty($image_url)) { return false; } else { $image_id = empty($image_id) && !empty($image_url) ? rt_get_attachment_id_from_src($image_url) : $image_id; $image_thumb = !empty($image_id) ? rt_vt_resize($image_id, '', $w, $h, $crop) : rt_vt_resize('', $image_url, $w, $h, $crop); $image_alternative_text = !empty($image_id) ? get_post_meta($image_id, '_wp_attachment_image_alt', true) : ""; $image_output = is_array($image_thumb) ? '<img src="' . $image_thumb['url'] . '" alt="' . $image_alternative_text . '" class="' . $class . '" />' : ""; return $image_output; } }
function rt_get_image_data($args) { global $post; //args extract(shortcode_atts(array("image_id" => "", "image_url" => "", "w" => "", "h" => "", "crop" => false), $args)); //save the global post if any $save_post = $post; //find post id from src $image_id = !empty($image_id) ? $image_id : isset($image_url) ? rt_get_attachment_id_from_src($image_url) : ""; //get the post attachment $attachment = !empty($image_id) ? get_post($image_id) : false; if ($attachment) { //attachment data $image_title = $attachment->post_title; $image_caption = $attachment->post_excerpt; $image_description = $attachment->post_content; $image_alternative_text = get_post_meta($image_id, '_wp_attachment_image_alt', true); //image url - if not provided $orginal_image_url = !empty($image_url) ? $attachment->guid : $image_url; //resized img src - resize the image if $w and $h suplied $thumbnail_url = !empty($w) && !empty($h) ? rt_vt_resize($image_id, '', $w, $h, $crop) : $orginal_image_url; $thumbnail_url = is_array($thumbnail_url) ? $thumbnail_url["url"] : $thumbnail_url; // Tiny image thumbnail for lightbox gallery feature $lightbox_thumbnail = rt_vt_resize($image_id, '', 75, 50, true); $lightbox_thumbnail = is_array($lightbox_thumbnail) ? $lightbox_thumbnail["url"] : $thumbnail_url; } //give back the global post $post = $save_post; if ($attachment) { //output return array("image_title" => $image_title, "image_caption" => $image_caption, "image_alternative_text" => $image_alternative_text, "image_url" => $orginal_image_url, "thumbnail_url" => $thumbnail_url, "lightbox_thumbnail" => $lightbox_thumbnail); } else { //output return array("image_title" => "", "image_caption" => "", "image_alternative_text" => "", "image_url" => $image_url, "thumbnail_url" => $image_url, "lightbox_thumbnail" => $image_url); } }
$disable_lightbox = get_post_meta($post->ID, RT_COMMON_THEMESLUG . '_disable_lightbox', true); $external_link = get_post_meta($post->ID, RT_COMMON_THEMESLUG . '_external_link', true); $permalink = !empty($external_link) ? $external_link : get_permalink(); $open_in_new_tab = get_post_meta($post->ID, RT_COMMON_THEMESLUG . '_open_in_new_tab', true); $target = !empty($open_in_new_tab) ? '_blank' : "_self"; //link target //is crop active $rt_crop = get_option(RT_THEMESLUG . '_portfolio_image_crop') ? "true" : ""; //image max height $h = $rt_crop ? get_option(RT_THEMESLUG . '_portfolio_image_height') : 10000; //Thumbnail dimensions $w = rt_get_min_resize_size($rt_item_width); // Create thumbnail image $thumbnail_image_output = !empty($custom_thumb) ? get_resized_image_output(array("image_url" => trim($custom_thumb), "image_id" => "", "w" => $w, "h" => $h, "crop" => $rt_crop)) : get_resized_image_output(array("image_url" => trim($image), "image_id" => "", "w" => $w, "h" => $h, "crop" => $rt_crop)); // Tiny image thumbnail for lightbox gallery feature $lightbox_thumbnail = !empty($custom_thumb) ? rt_vt_resize('', $custom_thumb, 75, 50, true) : rt_vt_resize('', $image, 75, 50, true); $lightbox_thumbnail = is_array($lightbox_thumbnail) ? $lightbox_thumbnail["url"] : $image; $single_link_icon = $permalink && !$remove_link && !$disable_lightbox ? "" : "single"; ?> <?php /* * * CONTENT FOR CATEOGORIES OR OTHER PORTFOLIO LISTS * */ ?> <?php if (!is_singular('portfolio')) {
function rt_shortcode_slider_slides($atts, $content = null) { //[slide link="link" title="title" img_url="" video_url="" styling="" title_color="" title_bg_color="" text_color="" text_bg_color="" title_size="" text_size=""]slide_text[/slide] global $rt_slider_width, $rt_slider_height, $rt_slider_script, $rt_total_slide, $rt_slide_count, $rt_caption_output, $rt_slide_output, $rt_slider_id, $rt_image_resize, $rt_image_crop; $text = $image_output = $resized_img_url = ""; $rt_slide_count++; //defaults extract(shortcode_atts(array("link" => '', "title" => '', "title2" => '', "img_url" => '', "video_url" => '', "text_align" => 'left', "stretch_images" => true, "styling" => "", "title_color" => "", "title_bg_color" => "", "text_color" => "", "text_bg_color" => "", "title_size" => "", "text_size" => ""), $atts)); //nivo slide id $nivo_slide_id = $rt_slider_script == "nivo_slider" ? "random_" . rand(100000, 1000000) : ""; //randomized $nivo_image_sync_id = $nivo_slide_id ? "#" . $nivo_slide_id : ""; //caption css $caption_css = ""; if ($styling == "new") { $caption_css .= !empty($title_color) ? " color:" . rt_rgba2hex($title_color) . "; color:" . $title_color . ";" : ""; $caption_css .= !empty($title_bg_color) ? "background-image:none; background-color:" . rt_rgba2hex($title_bg_color) . "; background-color:" . $title_bg_color . ";" : "background-color:transparent;padding-top:0;padding-bottom:0;"; $caption_css .= !empty($title_size) ? " font-size:" . str_replace("px", "", $title_size) . "px;line-height:140%;" : ""; $caption_css = !empty($caption_css) ? 'style="' . $caption_css . '"' : ""; } //text css $text_css = ""; if ($styling == "new") { $text_css .= !empty($text_color) ? " color:" . rt_rgba2hex($text_color) . "; color:" . $text_color . ";" : ""; $text_css .= !empty($text_bg_color) ? "background-image:none; background-color:" . rt_rgba2hex($text_bg_color) . "; background-color:" . $text_bg_color . ";" : "background-color:transparent;padding-top:0;padding-bottom:0;"; $text_css .= !empty($text_size) ? " font-size:" . str_replace("px", "", $text_size) . "px;line-height:140%;" : ""; $text_css = !empty($text_css) ? 'style="' . $text_css . '"' : ""; } //allowed html codes $allowed_html_title = array('br' => array()); $allowed_html_text = array('a' => array('href' => array(), 'title' => array()), 'br' => array(), 'em' => array(), 'strong' => array()); //title $title = !empty($title) ? !empty($link) ? '<div class="caption-one" ' . $caption_css . '><a href="' . $link . '" title="' . wp_kses($title, "") . '" ' . $caption_css . '>' . wp_kses(stripcslashes($title), $allowed_html_title) . '</a></div>' . "\n" : '<div class="caption-one" ' . $caption_css . '>' . wp_kses($title, $allowed_html_title) . '</div>' . "\n" : ""; //text $text = !empty($content) ? '<div class="caption-text" ' . $text_css . '>' . trim(wp_kses(stripcslashes($content), $allowed_html_text)) . '</div>' . "\n" : ""; //li class $li_class = $stretch_images == "true" ? "stretch" : ""; //featured image output if (!empty($img_url)) { $img_url = rt_find_image_org_path($img_url); $image_id = rt_get_attachment_id_from_src($img_url); $image_alternative_text = get_post_meta($image_id, '_wp_attachment_image_alt', true); $image_meta_data = wp_get_attachment_metadata($image_id, "true"); $image_height = isset($image_meta_data["height"]) ? $image_meta_data["height"] : ""; //crop & resize = true if (!empty($rt_image_resize) && !empty($rt_image_crop)) { $resized_img_url = rt_vt_resize($image_id, $img_url, $rt_slider_width, $rt_slider_height, true, false); } //crop = true & resize = false if (empty($rt_image_resize) && !empty($rt_image_crop)) { $resized_img_url = rt_vt_resize($image_id, $img_url, $rt_slider_width, $rt_slider_height, false, true); } //crop = false & resize = true if (!empty($rt_image_resize) && empty($rt_image_crop)) { $resized_img_url = rt_vt_resize($image_id, $img_url, $rt_slider_width, $rt_slider_height, false, false); } //if resized or cropped if (isset($resized_img_url) && is_array($resized_img_url)) { $img_url = $resized_img_url["url"]; $image_height = $resized_img_url["height"]; } //first image height $rt_first_slide_height = $rt_slide_count == 1 && $image_height ? $image_height : 0; $rt_first_slide_data = $rt_slide_count == 1 ? 'data-flexfirstslide="true"' : ""; $rt_first_slide_height_data = isset($rt_first_slide_height) && $rt_first_slide_height > 0 ? 'data-sliderminheight="' . $rt_first_slide_height . 'px"' : ""; $image_output = !empty($link) ? sprintf('<a href="%s"><img src="%s" alt="%s" title="%s" /></a>' . "\n", $link, $img_url, $image_alternative_text, $nivo_image_sync_id) : sprintf('<img src="%s" alt="%s" title="%s" />' . "\n", $img_url, $image_alternative_text, $nivo_image_sync_id); } //output for flexslider if ($rt_slider_script == "flex_slider") { //caption $rt_caption_output = !empty($title) || !empty($text) ? sprintf('<div class="flex-caption %s"><div class="caption-holder">%s %s %s</div></div>' . "\n", $text_align, $title, $title2, $text) : ""; //slide output $rt_slide_output = sprintf('<li class="%s" %s %s><div class="slide_data">%s %s</div></li>' . "\n", $li_class, $rt_first_slide_height_data, $rt_first_slide_data, $image_output, $rt_caption_output); return $rt_slide_output; } //output for nivoslider if ($rt_slider_script == "nivo_slider") { //caption $rt_caption_output .= !empty($title) || !empty($text) ? sprintf(' <div id="%s" class="nivo-html-caption"> <div class="nivo-title caption-%s"> %s </div> <div class="nivo-text"> %s </div> </div> ' . "\n", $nivo_slide_id, $rt_slide_count, $title, $text) : ""; //slide output $rt_slide_output .= sprintf("%s", $image_output); if ($rt_total_slide == $rt_slide_count) { //the slider holder output $rt_slide_output = sprintf(' <div class="nivo-container theme-default"> <div class="nivoSlider" id="%s"> %s </div> %s </div> ', $rt_slider_id, $rt_slide_output, $rt_caption_output); return $rt_slide_output; } } }
/** * Get post values for single portfolio pages * gets data of a portfolio item including metas * * @param array $post * @param array $atts * @return array */ function rt_get_portfolio_single_post_values($post = array(), $atts = array()) { //defaults $atts = shortcode_atts(array("layout" => "1/1", "featured_image_max_height" => 1000, "featured_image_crop" => "false", "hide_featured_image_single_page" => get_post_meta($post->ID, RT_COMMON_THEMESLUG . '_hide_featured_image_single_page', true), "show_share_buttons" => "true"), $atts); extract($atts); //featured image $featured_image_id = get_post_thumbnail_id(); $featured_image_url = !empty($featured_image_id) ? wp_get_attachment_image_src($featured_image_id, "full") : ""; $featured_image_url = is_array($featured_image_url) ? $featured_image_url[0] : ""; //custom thumbnail max height & crop settings for this post $this_featured_image_settings = get_post_meta($post->ID, RT_COMMON_THEMESLUG . '_featured_image_settings', true); $featured_image_max_height = $this_featured_image_settings == "new" ? get_post_meta($post->ID, RT_COMMON_THEMESLUG . '_portfolio_image_height', true) : $featured_image_max_height; $featured_image_crop = $this_featured_image_settings == "new" ? get_post_meta($post->ID, RT_COMMON_THEMESLUG . '_portfolio_image_crop', true) : $featured_image_crop; //featured media width $featured_media_width = get_post_meta($post->ID, RT_COMMON_THEMESLUG . '_portfolio_featured_media_width', true); $featured_media_width = !empty($featured_media_width); // thumbnail min width $w = !$featured_media_width ? rt_get_min_resize_size($layout) : 10000; // thumbnail max height $h = 10000; //thumbnail output $thumbnail_image_output = !empty($featured_image_id) ? get_resized_image_output(array("image_url" => "", "image_id" => $featured_image_id, "w" => $w, "h" => $h, "crop" => false)) : ""; // Tiny image thumbnail for lightbox gallery feature $lightbox_thumbnail = !empty($featured_image_id) ? rt_vt_resize($featured_image_id, "", 75, 50, true) : rt_vt_resize($featured_image_id, "", 75, 50, true); $lightbox_thumbnail = is_array($lightbox_thumbnail) ? $lightbox_thumbnail["url"] : ""; // gallery images $rt_gallery_images = get_post_meta($post->ID, RT_COMMON_THEMESLUG . "rt_gallery_images", true); $rt_gallery_images = !empty($rt_gallery_images) ? !is_array($rt_gallery_images) ? explode(",", $rt_gallery_images) : $rt_gallery_images : array(); //turn into an array //get post format $portfolio_format = get_post_meta($post->ID, RT_COMMON_THEMESLUG . '_portfolio_post_format', true); $portfolio_format = empty($portfolio_format) ? "image" : $portfolio_format; //permalink $permalink = !empty($remove_link) ? "" : get_permalink(); $permalink = !empty($external_link) ? $external_link : $permalink; //no media for image post type $no_featured_media = $portfolio_format == "image" && empty($rt_gallery_images) && (empty($featured_image_url) || $featured_image_url && $hide_featured_image_single_page) ? true : false; //create global values array $rt_portfolio_post_values = array("title" => get_the_title(), "permalink" => $permalink, "featured_image_id" => $featured_image_id, "featured_image_url" => $featured_image_url, "portfolio_format" => $portfolio_format, "video_mp4" => get_post_meta($post->ID, RT_COMMON_THEMESLUG . '_portfolio_video_m4v', true), "video_webm" => get_post_meta($post->ID, RT_COMMON_THEMESLUG . '_portfolio_video_webm', true), "external_video" => get_post_meta($post->ID, RT_COMMON_THEMESLUG . '_portfolio_video', true), "audio_mp3" => get_post_meta($post->ID, RT_COMMON_THEMESLUG . '_portfolio_audio_mp3', true), "audio_ogg" => get_post_meta($post->ID, RT_COMMON_THEMESLUG . '_portfolio_audio_oga', true), "gallery_images" => $rt_gallery_images, "gallery_usage" => get_post_meta($post->ID, RT_COMMON_THEMESLUG . '_featured_image_usage', true), "gallery_images_crop" => get_post_meta($post->ID, RT_COMMON_THEMESLUG . 'image_crop', true), "gallery_images_max_height" => get_post_meta($post->ID, RT_COMMON_THEMESLUG . 'portfolio_max_image_height', true), "gallery_layout" => get_post_meta($post->ID, RT_COMMON_THEMESLUG . '_gallery_layout', true), "thumbnail_image_output" => $thumbnail_image_output, "lightbox_thumbnail" => $lightbox_thumbnail, "featured_media_width" => $featured_media_width, "no_featured_media" => $no_featured_media); $rt_portfolio_post_values = array_merge($rt_portfolio_post_values, $atts); return $rt_portfolio_post_values; }
* Thumbnail image output & video url */ $video_url = $video_image = ""; //external video url provided if (!empty($video) && !empty($external_video_poster_image)) { $video_image = $external_video_poster_image; $video_url = $video; } //local video url provided if (!empty($portfolio_video_m4v) && !empty($local_video_poster_image)) { $video_image = $local_video_poster_image; $video_url = $portfolio_video_m4v; } $image_output = get_resized_image_output(array("image_url" => trim($video_image), "image_id" => "", "w" => $w, "h" => $h, "crop" => $rt_crop)); //video image thumbnail for lightbox $video_image_thumbnail = !empty($video_image) ? rt_vt_resize('', $video_image, 75, 50, true) : ""; $video_image_thumbnail = is_array($video_image_thumbnail) ? $video_image_thumbnail["url"] : $video_image; //single icons $single_action_icon = !$permalink || $remove_link ? "single" : ""; $single_link_icon = !empty($disable_lightbox) ? "single" : ""; ?> <?php /* * * CONTENT FOR CATEOGORIES OR OTHER PORTFOLIO LISTS * */ ?>
$disable_lightbox = get_post_meta($post->ID, RT_COMMON_THEMESLUG . '_disable_lightbox', true); $external_link = get_post_meta($post->ID, RT_COMMON_THEMESLUG . '_external_link', true); $permalink = !empty($external_link) ? $external_link : get_permalink(); $open_in_new_tab = get_post_meta($post->ID, RT_COMMON_THEMESLUG . '_open_in_new_tab', true); $target = !empty($open_in_new_tab) ? '_blank' : "_self"; //link target //is crop active $rt_crop = get_option(RT_THEMESLUG . '_portfolio_image_crop') ? "true" : ""; //image max height $h = $rt_crop ? get_option(RT_THEMESLUG . '_portfolio_image_height') : 10000; //Thumbnail dimensions $w = rt_get_min_resize_size($rt_item_width); //Thumbnail image output $image_output = !empty($image) ? get_resized_image_output(array("image_url" => trim($image), "image_id" => "", "w" => $w, "h" => $h, "crop" => $rt_crop)) : ""; //video image thumbnail for lightbox $audio_image_thumbnail = !empty($image) ? rt_vt_resize('', $image, 75, 50, true) : ""; $audio_image_thumbnail = is_array($audio_image_thumbnail) ? $audio_image_thumbnail["url"] : $image; //single icons $single_action_icon = !$permalink || $remove_link ? "single" : ""; $single_link_icon = !empty($disable_lightbox) ? "single" : ""; ?> <?php /* * * CONTENT FOR CATEOGORIES OR OTHER PORTFOLIO LISTS *