</div>'; } $this_post_media_counter++; } echo '</div>'; //} ?> <?php } else { ?> <?php $_featured_video = get_post_meta(get_the_ID(), '_featured_video', true); if ($_featured_video) { ?> <?php echo miss_video(array('url' => $_featured_video, 'width' => 490, 'height' => 270, 'parse' => 1)); ?> <?php } else { ?> <?php if (miss_get_post_image(array('width' => 490, 'height' => 267, 'echo' => false)) != '') { ?> <div class="image-row"> <div class="preview-container preview-largest base-preview" style="height: 267px; line-height: 267px;"> <div class="preview-image"> <?php echo miss_get_post_image(array('width' => 490, 'height' => 267, 'echo' => false)); ?> </div> <div class="preview-info-wrapper">
/** * */ function miss_wp_image($image, $width = '', $height = '') { if (empty($image)) { return; } global $irish_framework_params; $miss_wp_upload_dir = wp_upload_dir(); $image_path = explode(home_url('/'), $image); $image_path = ABSPATH . $image_path[1]; if (preg_match("((https|ftp|http)\\:\\/\\/)", $image) && function_exists('ini_get') && ini_get('allow_url_fopen')) { $file_signature = miss_get_remote_file_date($image); } else { $file_signature = miss_get_local_file_date($image); } $image_info = pathinfo($image_path); $image_sizes = @getimagesize($image_path); # If we cannot get the image locally, try for an external URL if (empty($image_sizes)) { $image_sizes = @getimagesize($image); } if (miss_video($args = array('url' => $image))) { $image = THEME_IMAGES_ASSETS . '/movie_thumb.png'; } elseif (empty($image_sizes)) { $image = THEME_IMAGES_ASSETS . '/no-image.png'; } if (!miss_is_cache_writable()) { return $image; } $image_sizes[0] = !empty($image_sizes[0]) ? $image_sizes[0] : ''; $image_sizes[1] = !empty($image_sizes[1]) ? $image_sizes[1] : ''; # Auto crop width if (empty($width) || !is_numeric($width)) { $width = miss_auto_width(array('width' => $width, 'get_width' => $image_sizes[0])); } $width = !empty($_POST['img_width']) ? $_POST['img_width'] : (!empty($width) ? trim(str_replace(' ', '', str_replace('px', '', $width))) : $image_sizes[0]); $height = !empty($_POST['img_height']) ? $_POST['img_height'] : (!empty($height) ? trim(str_replace(' ', '', str_replace('px', '', $height))) : $image_sizes[1]); $image_src[0] = THEME_CACHE_URI . '/' . basename($image); $image_src[1] = $image_sizes[0]; $image_src[2] = $image_sizes[1]; $extension = '.' . $image_info['extension']; $no_ext_path = THEME_CACHE . '/' . $image_info['filename']; // Safe image cache $safe_file_name = md5($image_info['filename'] . '-' . $width . 'x' . $height . '-' . $file_signature); $safe_file_path = ''; // Build safe directory structure if (is_writable(THEME_CACHE)) { $path_levels = array(1 => substr($safe_file_name, 0, 1)); // Level #1 if (is_array($path_levels)) { if (!file_exists(THEME_CACHE . '/' . $safe_file_path . '/' . $path_levels[1])) { if (@mkdir(THEME_CACHE . '/' . $safe_file_path . '/' . $path_levels[1])) { $safe_file_path .= $path_levels[1]; @touch(THEME_CACHE . '/' . $safe_file_path . '/index.html'); } else { $path_levels = false; } } else { $safe_file_path .= $path_levels[1]; } } } $cropped_img_path = THEME_CACHE . '/' . $safe_file_path . '/' . $safe_file_name . $extension; $cropped_img_uri = $safe_file_path . '/' . $safe_file_name . $extension; # checking if the file size is larger than the target size # if it is smaller or the same size, stop right here and return if ($image_src[1] > $width || $image_src[2] > $height) { # the file is larger, check if the resized version already exists if (file_exists($cropped_img_path)) { $image = str_replace(basename($image_src[0]), $cropped_img_uri, $image_src[0]); } if (!file_exists($cropped_img_path)) { $new_img_obj = wp_get_image_editor($image_path); // If there's an error lets try WordPress's ABSPATH instead of $_SERVER['DOCUMENT_ROOT'] if (is_wp_error($new_img_obj)) { $new_img_obj = wp_get_image_editor($image_path); if (is_wp_error($new_img_obj) && function_exists('image_resize')) { $cropped_img_path = image_resize($image_path, $width, $height, $crop = true, $suffix = null, $dest_path = $safe_file_path); if (is_wp_error($new_img_obj)) { return false; } } else { $new_img_obj->resize($width, $height, true); $new_img_obj->save($cropped_img_path); } } else { $new_img_obj->resize($width, $height, true); $new_img_obj->save($cropped_img_path); } $new_img_path = $cropped_img_path; $new_img_size = getimagesize((string) $cropped_img_path); $image = str_replace(basename($image_src[0]), $cropped_img_uri, $image_src[0]); } } return $image; }
/** * */ public static function portfolio_grid($atts) { if ($atts == 'generator') { $option = array('name' => __('Portfolio Grid', MISS_ADMIN_TEXTDOMAIN), 'value' => 'portfolio_grid', 'options' => array(array('name' => __('Number of Columns', MISS_ADMIN_TEXTDOMAIN), 'desc' => __('Select the number of columns you would like your posts to display in.', MISS_ADMIN_TEXTDOMAIN), 'id' => 'column', 'default' => '', 'options' => array('1' => __('One Column', MISS_ADMIN_TEXTDOMAIN), '2' => __('Two Column', MISS_ADMIN_TEXTDOMAIN), '3' => __('Three Column', MISS_ADMIN_TEXTDOMAIN), '4' => __('Four Column', MISS_ADMIN_TEXTDOMAIN)), 'type' => 'select'), array('name' => __('Number of Portfolio Posts', MISS_ADMIN_TEXTDOMAIN), 'desc' => __('Select the number of posts you would like to display on each page.', MISS_ADMIN_TEXTDOMAIN), 'id' => 'showposts', 'default' => '', 'options' => array_combine(range(1, 40), array_values(range(1, 40))), 'type' => 'select'), array('name' => __('Portfolio Categories <small>(optional)</small>', MISS_ADMIN_TEXTDOMAIN), 'desc' => __('Select which portfolio categories you would like to display.', MISS_ADMIN_TEXTDOMAIN), 'id' => 'cat', 'default' => array(), 'target' => 'portfolio_category', 'type' => 'select'), array('name' => __('Offset Portfolio Posts <small>(optional)</small>', MISS_ADMIN_TEXTDOMAIN), 'desc' => __('This will skip a number of posts at the beginning.<br /><br />Useful if you are using multiple portfolio shortcodes on the same page.', MISS_ADMIN_TEXTDOMAIN), 'id' => 'offset', 'default' => '', 'options' => array_combine(range(1, 10), array_values(range(1, 10))), 'type' => 'select'), array('name' => __('Disable Portfolio Elements <small>(optional)</small>', MISS_ADMIN_TEXTDOMAIN), 'desc' => __('You can hide certain elements from displaying here.', MISS_ADMIN_TEXTDOMAIN), 'id' => 'disable', 'options' => array('image' => __('Disable Post Image', MISS_ADMIN_TEXTDOMAIN), 'title' => __('Disable Post Title', MISS_ADMIN_TEXTDOMAIN), 'excerpt' => __('Disable Post Excerpt', MISS_ADMIN_TEXTDOMAIN), 'date' => __('Disable Date', MISS_ADMIN_TEXTDOMAIN), 'more' => __('Disable Read More', MISS_ADMIN_TEXTDOMAIN), 'visit' => __('Disable Visit Site', MISS_ADMIN_TEXTDOMAIN), 'pagination' => __('Disable Pagination', MISS_ADMIN_TEXTDOMAIN)), 'default' => '', 'type' => 'checkbox'), 'shortcode_has_atts' => true)); return $option; } extract(shortcode_atts(array('column' => '4', 'showposts' => '8', 'cat' => array(), 'offset' => '', 'disable' => ''), $atts)); $out = ''; $portfolio_query = new WP_Query(); if (isset($cat)) { global $post, $wp_rewrite, $wp_query, $irish_framework_params; $column = trim($column); $showposts = trim($showposts); // $cat = trim( $cat ); $offset = trim($offset); if (is_front_page()) { $_layout = miss_get_setting('homepage_layout'); // $images = ( $_layout == 'full_width' ? 'images' : ( $_layout == 'left_sidebar' ? 'small_sidebar_images' : 'big_sidebar_images' ) ); } else { $post_obj = $wp_query->get_queried_object(); $_layout = get_post_meta($post_obj->ID, '_layout', true); // $images = ( $_layout == 'full_width' ? 'images' : ( $_layout == 'left_sidebar' ? 'small_sidebar_images' : 'big_sidebar_images' ) ); } $paged = miss_get_page_query(); $gallery_post = $post->post_name; if ($post->post_parent) { $parent_query = get_post($post->post_parent); $gallery_parent = $parent_query->ID; } if (is_numeric($offset) && strpos($disable, 'pagination') === false) { $irish_framework_params->offset = $offset; $irish_framework_params->posts_per_page = $showposts; add_filter('post_limits', 'my_post_limit'); } if (strpos($disable, 'pagination') === false) { $args = array('post_type' => 'portfolio', 'posts_per_page' => $showposts, 'taxonomy' => 'portfolio_category', 'term' => $cat, 'offset' => $offset, 'paged' => $paged); } else { $args = array('post_type' => 'portfolio', 'showposts' => $showposts, 'taxonomy' => 'portfolio_category', 'term' => $cat, 'offset' => $offset, 'nopaging' => 0); } if (isset($cat) && !empty($cat)) { $args['tax_query'] = array(array('taxonomy' => 'portfolio_category', 'field' => 'slug', 'terms' => $cat)); } $portfolio_query = new WP_Query(); $portfolio_query->query($args); } if ($portfolio_query->have_posts()) { $img_sizes = $irish_framework_params->layout['big_sidebar_images']; $img_group = 'portfolio_img_group_' . rand(1, 1000); $width = ''; $height = ''; switch ($column) { case 1: $column_class = 'span12 has_preview'; $width = $img_sizes['span12'][0]; $height = $img_sizes['span12'][1]; break; case 2: $column_class = 'span6 has_preview'; $width = $img_sizes['span6'][0]; $height = $img_sizes['span6'][1]; break; case 3: $column_class = 'span4 has_preview'; $width = $img_sizes['span4'][0]; $height = $img_sizes['span4'][1]; break; case 4: $column_class = 'span3 has_preview'; $width = $img_sizes['span3'][0]; $height = $img_sizes['span3'][1]; break; } $main_class = 'loop_module works portfolio row-fluid'; $out .= '<div class="' . $main_class . '">'; $i = 1; while ($portfolio_query->have_posts()) { $portfolio_query->the_post(); $id = get_the_ID(); $custom_fields = get_post_custom($id); foreach ($custom_fields as $key => $value) { ${$key}[$id] = $value[0]; if (is_serialized(${$key}[$id])) { ${$key}[$id] = unserialize(${$key}[$id]); } } if (has_post_thumbnail() || !empty($_image[$id]) || !empty($_featured_video[$id])) { if (has_post_thumbnail()) { $img = wp_get_attachment_image_src(get_post_thumbnail_id($id), 'full', true); } else { $img[0] = !empty($_image[$id]) ? $_image[$id] : ''; } if ($wp_rewrite->using_permalinks()) { $url = home_url('/') . 'portfolio/' . $post->post_name . '/gallery/' . $gallery_post . '/'; } else { $url = htmlspecialchars(add_query_arg(array('gallery' => $gallery_post), get_permalink($id))); } $link_to = empty($_post[$id][0]) ? empty($_featured_video[$id]) ? empty($_image[$id]) ? $img[0] : $_image[$id] : $_featured_video[$id] : $url; $out .= '<div class="portfolio_item ' . ($i % $column == 0 ? $column_class . ' last' : $column_class) . ' im-transform im-animate-element scale-up">'; $out .= '<div class="' . join(' ', get_post_class('post_grid_module', get_the_ID())) . '">'; if (strpos($disable, 'image') === false) { $offset = $irish_framework_params->layout['images']['image_padding']; $load_width = $width + $offset; $load_height = $height + $offset; $out .= '<div class="post_grid_image" data-style="width:' . $load_width . 'px;">'; ob_start(); miss_portfolio_image_begin(); $out .= ob_get_clean(); if (empty($img[0]) && !empty($_featured_video[$id])) { $video_check = miss_video($args = array('url' => $_featured_video[$id], 'parse' => true, 'width' => $width, 'height' => $height)); } else { $video_check = false; } if (!empty($video_check)) { $out .= $video_check; } else { $out .= miss_display_image(array('src' => $img[0], 'alt' => '', 'title' => '', 'height' => $height, 'width' => $width, 'class' => 'hover_fade_js', 'link_to' => $link_to, 'img_class' => 'post_grid_image has_preview', 'link_class' => 'portfolio_img_load', 'prettyphoto' => empty($_post[$id][0]) ? true : false, 'group' => $img_group, 'preload' => false)); } ob_start(); miss_portfolio_image_end(array('column' => $column, 'disable' => $disable, 'date' => !empty($_date[$id]) ? $_date[$id] : '')); $out .= ob_get_clean(); $out .= '</div>'; } $out .= '<div class="first_layer color_frame">'; $out .= '<div class="second_layer sidebar_framed_caption">'; if (strpos($disable, 'title') === false) { $out .= '<div class="portfolio_item_title"><a href="' . get_permalink() . '">' . get_the_title() . '</a></div>'; // $title = ( empty( $_more[$id][0] ) ) ? '<a href="' . esc_url( $url ) . '">' . get_the_title( $id ) . '</a>' : get_the_title( $id ); /* if( $column == 1 || $column == 2 ) $out .= '<h2 class="post_title">' . $title . '</h2>'; else $out .= '<h3 class="post_title">' . $title . '</h3>'; */ } if (strpos($disable, 'meta') === false) { $out .= '<div class="portfolio_item_meta">' . miss_post_meta_diferent(array('echo' => false)) . '</div>'; } /* if( ( !empty( $_date[$id] ) ) && ( strpos( $disable, 'date' ) === false ) ) $out .= apply_filters( 'miss_portfolio_date', '<p class="date">' . $_date[$id] . '</p>', array( 'column' => $column ) ); if( empty( $_more[$id][0] ) || !empty( $_link[$id] ) || !empty( $_teaser[$id] ) ) { $out .= '<div class="post_excerpt">'; $out .= ( ( !empty( $_teaser[$id] ) ) && ( strpos( $disable, 'excerpt' ) === false ) ) ? '<p>' . do_shortcode( $_teaser[$id] ) . '</p>' : ''; if( empty( $_more[$id][0] ) || !empty( $_link[$id] ) ) { $out .= '<p>'; */ /* if( ( empty( $_more[$id][0] ) ) && ( strpos( $disable, 'more' ) === false ) ) { $read_more = '<a href="' . esc_url( $url ) . '" class="post_more_link">' . __( 'Read More', MISS_TEXTDOMAIN ) . '</a> '; $out .= apply_filters( 'miss_portfolio_read_more', $read_more, esc_url( $url ) ); } if( ( !empty( $_link[$id] ) ) && ( strpos( $disable, 'visit' ) === false ) ) { $visit_site = '<a href="' . esc_url( $_link[$id] ) . '" class="post_more_link">' . __( 'Visit Site', MISS_TEXTDOMAIN ) . '</a>'; $out .= apply_filters( 'miss_portfolio_visit_site', $visit_site, esc_url( $_link[$id] ) ); } */ /* $out .= '</p>'; } $out .= '</div>'; } */ $out .= '</div><!-- /.second_layer-->'; $out .= '</div><!-- /.first_layer-->'; $out .= '</div>'; $out .= '</div><!-- /.portfolio_item -->'; if ($i % $column == 0) { $out .= '<div class="clearboth"></div>'; } $i++; } } $out .= '</div>'; $out .= strpos($disable, 'pagination') === false ? miss_pagenavi('', '', $portfolio_query) : ''; } else { $out .= __('No portfolio posts were found for the category selected.', MISS_TEXTDOMAIN); } if (is_numeric($offset) && strpos($disable, 'pagination') === false) { remove_filter('post_limits', 'my_post_limit'); } wp_reset_query(); //return '[raw]' . $out . '[/raw]'; return $out; }