function max_get_timthumb_image($return = false, $p_id = false, $img_size = 'full') { global $post, $imgDimensions, $imgDimensions1x, $p_tpl, $resize_images, $is_retina; $max_mobile_detect = new Mobile_Detect(); // get the sting we need for the different devices $size = $img_size; // set the attachment image size $post_id = !$p_id ? $post->ID : $p_id; // check if its a lightbox or a project page link $photo_item_type = get_post_meta($post_id, MAX_SHORTNAME . '_photo_item_type_value', true); // get the item type $imgUrl = max_get_post_image_url($post_id, $size); // Get the post image url $tpl_show_lightbox = get_post_meta(get_query_var('page_id'), MAX_SHORTNAME . '_disable_post_lightbox', true); // check to show the lightbox on this page template $use_timthumb = get_option_max('image_use_timthumb'); $pretty_rel = get_option_max('pretty_enable_lightbox', 'false') == 'false' ? ' data-rel="prettyPhoto"' : ''; $pretty_rel_gal = get_option_max('pretty_enable_lightbox', 'false') == 'false' ? ' data-rel="prettyPhoto[gal]"' : ''; // calculate the image dimensions if ($max_mobile_detect->isMobile() && !$max_mobile_detect->isTablet() && !empty($imgDimensions1x) && is_array($imgDimensions1x)) { // its a mobile phone device so we need other images to display properly $_dimensions = max_calculate_image($imgDimensions1x, $imgUrl); } else { $_dimensions = max_calculate_image($imgDimensions, $imgUrl); // desktop images are larger } // Build the image link if (has_post_thumbnail($post_id)) { // Get Image URL $imgSrc = max_get_image_path($post_id); $imgFull = max_get_post_image_url($post_id); // get the title $title = !get_the_excerpt() ? '' : ' title="' . strip_tags(htmlspecialchars(get_the_excerpt())) . '"'; $alt = ' alt="' . strip_tags(get_the_title()) . '"'; $cat_list = array(); foreach (get_the_category() as $category) { $cat_list[] = $category->cat_ID; } $output = ""; // check if we have to show a link or links are disabled if ($photo_item_type != "Disable Link" && $photo_item_type != 'disable_link') { // check if option to show lightbox on this page template is enabled if (empty($tpl_show_lightbox) || $tpl_show_lightbox == 'false') { if ($photo_item_type == "Lightbox" || $photo_item_type == 'lightbox' || $p_tpl == "template-lightbox.php" || get_option_max('image_always_lightbox') == 'true') { $lightbox_type = get_post_meta($post_id, MAX_SHORTNAME . '_photo_lightbox_type_value', true); $lightbox_link = get_post_meta($post_id, MAX_SHORTNAME . '_photo_item_custom_lightbox', true); if ($p_tpl == "template-lightbox.php") { // check for youtube or vimeo id if ($photo_item_type == 'youtube_embed') { $output .= '<a href="http://www.youtube.com/watch?v=' . get_post_meta($post_id, MAX_SHORTNAME . '_video_embeded_url_value', true) . '"' . $pretty_rel_gal . ' data-link="' . get_permalink($post_id) . '"' . $title . '>'; } else { if ($photo_item_type == 'vimeo_embed') { $output .= '<a href="http://www.vimeo.com/' . get_post_meta($post_id, MAX_SHORTNAME . '_video_embeded_url_value', true) . '"' . $pretty_rel_gal . ' data-link="' . get_permalink($post_id) . '"' . $title . '>'; } else { if ($photo_item_type == 'selfhosted_embed' || $photo_item_type == 'selfhosted') { $output .= '<a href="' . get_post_meta($post_id, MAX_SHORTNAME . '_video_url_m4v_value', true) . '?iframe=true" ' . $pretty_rel_gal . ' data-link="' . get_permalink($post_id) . '"' . $title . '>'; // check for lightbox videos } else { if ($photo_item_type == 'lightbox' && $lightbox_type == 'vimeo') { $output .= '<a href="' . get_post_meta($post_id, MAX_SHORTNAME . '_photo_video_vimeo_value', true) . '"' . $pretty_rel . $title . ' data-link="' . get_permalink($post_id) . '">'; } else { if ($photo_item_type == 'lightbox' && $lightbox_type == 'youtube') { $output .= '<a href="' . get_post_meta($post_id, MAX_SHORTNAME . '_photo_video_youtube_value', true) . '"' . $pretty_rel . $title . ' data-link="' . get_permalink($post_id) . '">'; // by default get the featured image } else { $output .= '<a href="' . $imgFull[0] . '"' . $pretty_rel_gal . ' data-link="' . get_permalink($post_id) . '"' . $title . '>'; } } } } } } else { // Display Lightbox custom link if (!empty($lightbox_link) && $lightbox_type == 'custom') { $output .= '<a href="' . $lightbox_link . '?iframe=true&width=800&height=600" ' . $pretty_rel . ' data-link="' . get_permalink($post_id) . '"' . $title . '>'; } // Display Lightbox Photo if ($lightbox_type == "Photo" || $lightbox_type == "photo") { $output .= '<a href="' . $imgFull[0] . '"' . $pretty_rel_gal . ' data-link="' . get_permalink($post_id) . '"' . $title . '>'; } // Display Lightbox YouTube Video if ($lightbox_type == "YouTube-Video" || $lightbox_type == "youtube") { $output .= '<a href="' . get_post_meta($post_id, MAX_SHORTNAME . '_photo_video_youtube_value', true) . '"' . $pretty_rel . $title . ' data-link="' . get_permalink($post_id) . '">'; } // Display Lightbox Vimeo Video if ($lightbox_type == "Vimeo-Video" || $lightbox_type == "vimeo") { $output .= '<a href="' . get_post_meta($post_id, MAX_SHORTNAME . '_photo_video_vimeo_value', true) . '"' . $pretty_rel . $title . ' data-link="' . get_permalink($post_id) . '">'; } } } else { if ($photo_item_type == "Project Page" || $photo_item_type == 'projectpage' || $photo_item_type == 'selfhosted_embed' || $photo_item_type == 'selfhosted' || $photo_item_type == 'youtube_embed' || $photo_item_type == 'vimeo_embed') { // Photo Type is a Project Page $output .= '<a href="' . get_permalink($post_id) . '"' . $title . '>'; } else { if ($photo_item_type == "External Link" || $photo_item_type == 'external') { $target = get_post_meta($post_id, MAX_SHORTNAME . '_external_link_target_value', true); $str_target = isset($target) && $target != "" ? $target : "_blank"; // Photo Type is an external Link $output .= '<a href="' . get_post_meta($post_id, MAX_SHORTNAME . '_photo_external_link_value', true) . '" target="' . get_post_meta($post_id, MAX_SHORTNAME . '_external_link_target_value', true) . '"' . $title . '">'; } else { // Get the image link $output .= '<a href="' . $imgFull[0] . '"' . $pretty_rel . $title . ' data-link="' . get_permalink($post_id) . '">'; } } } } } // fallback to lightbox if something is wrong to not break the image link } else { if (empty($tpl_show_lightbox) || $tpl_show_lightbox == 'false') { // check if option to show lightbox on this page template is enabled // Get the image link $output .= '<a href="' . $imgFull[0] . '"' . $pretty_rel . $title . ' data-link="' . get_permalink($post_id) . '">'; } } // get the new image width calculation if no height or width is set if ($_dimensions['height'] == 0) { $_dimensions['height'] = ""; } if ($_dimensions['width'] == 0) { $_dimensions['width'] = ""; } // resize the image if needed otherwise get the cropped WP version if ($resize_images === true) { // change to retina image size if (!empty($is_retina) && true === $is_retina) { $_dimensions['height'] = $_dimensions['height'] * 2; $_dimensions['width'] = $_dimensions['width'] * 2; } $data1x_img = max_get_custom_image_url(get_post_thumbnail_id($post_id), false, $_dimensions['width'], $_dimensions['height'], get_cropping_direction(get_post_meta($post_id, MAX_SHORTNAME . '_photo_cropping_direction_value', true)), false, true); } else { // lets get the cropped WP version // retina size array $size_array = array('mobile' => 'large', 'large' => 'full', 'tablet' => 'full', 'full' => 'full'); // change to retina image size if (!empty($is_retina) && true === $is_retina) { $size = $size_array[$size]; } $_wp_image = max_get_post_image_url($post_id, $size); $data1x_img = $_wp_image[0]; } // get the image tag, it's always the same $output .= '<img src="' . $data1x_img . '" ' . $alt . ' data-src="' . $data1x_img . '" class="the-post-image" />'; // Close Link if its not a disabled link if ($photo_item_type != "Disable Link" && $photo_item_type != 'disable_link') { if (empty($tpl_show_lightbox) || $tpl_show_lightbox == 'false') { // check if option to show lightbox on this page template is enabled $output .= '</a>'; } } if ($return === true) { return $output; } else { echo $output; } }
} else { if (function_exists('has_post_thumbnail') && has_post_thumbnail()) { // Get the thumbnail $imgID = get_post_thumbnail_id(); $imgUrl_full = max_get_image_path($post->ID, 'full'); // Check if images should be cropped $timb_height = ''; $timb_img_height = ''; if (get_option_max('image_blog_detail_original_ratio') != 'true') { $timb_height = 250; if (get_option_max('general_show_fullblog_details', 'false') == 'true') { $timb_height = 354; } } // get the imgUrl for showing the post image $imgUrl = max_get_custom_image_url(get_post_thumbnail_ID(), get_the_ID(), $post_width, $timb_height, get_cropping_direction($meta[MAX_SHORTNAME . '_photo_cropping_direction_value'])); ?> <div class="entry-image"> <?php $img_excerpt = get_the_excerpt(); $img_title = get_the_title(); $img_alt = get_the_title(); // check wether to choose image or post meta informations on the lightbox if (get_option_max('general_use_image_meta') == 'true') { // get the meta from the image information on the media library $img_title = get_post_field('post_title', get_post_thumbnail_id()); $img_excerpt = get_post_field('post_excerpt', get_post_thumbnail_id()); $img_alt = get_post_field('_wp_attachment_image_alt', get_post_thumbnail_id()); }
?> </h3> <div id="max-preloader"> <div class="max-loader"> </div> </div> <ul id="portfolioList" class="clearfix portfolio-list"> <?php // start the posts loop while ($gallery_posts->have_posts()) { $gallery_posts->the_post(); // get the default image if we don't have to crop $_imgUrl = max_get_custom_image_url(get_post_thumbnail_id(get_the_ID()), null, 400, 300, get_cropping_direction(get_post_meta(get_the_ID(), MAX_SHORTNAME . '_photo_cropping_direction_value', true))); ?> <li data-id="id-<?php echo get_the_ID(); ?> " class="item <?php echo max_get_post_lightbox_class(); if (get_option_max('image_show_fade') != "true") { echo " no-hover"; } ?> "> <div class="shadow"> <?php echo '<a href="' . get_permalink() . '" title="' . strip_tags(get_the_title()) . '"><img src="' . $_imgUrl . '" alt="' . strip_tags(get_the_title()) . '" /></a>'; ?>
function related_posts_shortcode($atts) { extract(shortcode_atts(array('limit' => '4', 'width' => 400, 'height' => 300, 'taxonomy' => GALLERY_TAXONOMY), $atts)); global $post, $imgDimensions; $imgDimensions = array('width' => $width, 'height' => $height); if ($post->ID) { // Get tags $filter = 'post_tag'; $tags = wp_get_post_terms($post->ID, 'post_tag', array("fields" => "ids")); $list = ""; $tag_arr = ""; if ($tags) { $args = array('tag__in' => $tags, 'post__not_in' => array($post->ID), 'post_type' => get_post_type(), 'showposts' => $limit, 'ignore_sticky_posts' => 1); $related_posts = new WP_Query($args); if ($related_posts) { $list = '<div id="related-posts" class="entry-related-images portfolio-four-columns"><h3 class="related-title">' . __('Related Posts', MAX_SHORTNAME) . '</h3><ul class="clearfix portfolio-list">'; if ($related_posts->have_posts()) { while ($related_posts->have_posts()) { $related_posts->the_post(); if (has_post_thumbnail(get_the_ID())) { $hover_class = ""; if (get_option_max('image_show_fade') != "true") { $hover_class = ' no-hover'; } $list .= '<li class="item ' . max_get_post_lightbox_class() . $hover_class . '"><div class="shadow">'; // get the imgUrl for showing the post image $_imgUrl = max_get_custom_image_url(get_post_thumbnail_ID(get_the_ID()), get_the_ID(), esc_attr($width), esc_attr($height), get_cropping_direction(get_post_meta(get_the_ID(), MAX_SHORTNAME . '_photo_cropping_direction_value', true))); // get the gallery item $list .= '<a href="' . get_permalink(get_the_ID()) . '" title="' . get_the_title() . '"><img src="' . $_imgUrl . '" alt="' . get_the_title() . '" /></a></div>'; // check if caption option is selected if (get_option_max('image_show_caption') == 'true') { $list .= '<div class="item-caption"><strong>' . wptexturize(get_the_title()) . '</strong></div>'; } $list .= '</li>'; } else { continue; } } } wp_reset_query(); $list .= '</ul></div>'; } } return $list; } return; }
function widget($args, $instance) { global $imgDimensions; $cache = wp_cache_get('widget_my_custom_recent_posts', 'widget'); if (!is_array($cache)) { $cache = array(); } if (isset($cache[$args['widget_id']])) { echo $cache[$args['widget_id']]; return; } ob_start(); extract($args); $title = apply_filters('widget_title', empty($instance['title']) ? __('Recent Photostream', MAX_SHORTNAME) : $instance['title'], $instance, $this->id_base); if (!($number = (int) $instance['number'])) { $number = 10; } else { if ($number < 1) { $number = 1; } } // get the posts from gallery category you want to exclude $excluded_post_ids = get_objects_in_term(array(), GALLERY_TAXONOMY); $r = new WP_Query(array('showposts' => $number, 'nopaging' => 0, 'post_status' => 'publish', 'ignore_sticky_posts' => true, 'post_type' => array('gallery'), 'post__not_in' => $excluded_post_ids)); if ($r->have_posts()) { ?> <?php echo $before_widget; ?> <?php if ($title) { echo $before_title . $title . $after_title; } ?> <ul class="clearfix"> <?php while ($r->have_posts()) { $r->the_post(); ?> <li> <?php // get the post image $imgUrl = max_get_custom_image_url(get_post_thumbnail_ID(get_the_ID()), get_the_ID(), 200, 200, get_cropping_direction(get_post_meta(get_the_ID(), MAX_SHORTNAME . '_photo_cropping_direction_value', true))); // get the gallery item echo '<a href="' . get_permalink(get_the_ID()) . '" title="' . get_the_ID() . '"><img src="' . $imgUrl . '" width="50" height="50" alt="' . get_the_title() . '" class="fade-image"/></a>'; ?> </li> <?php } ?> </ul> <?php echo $after_widget; ?> <?php // Reset the global $the_post as this query will have stomped on it wp_reset_postdata(); } $cache[$args['widget_id']] = ob_get_flush(); wp_cache_set('widget_my_custom_recent_posts', $cache, 'widget'); }