Ejemplo n.º 1
0
 function ikra_image($url, $width = '', $height = '', $placeholder = true, $crop = true, $align = '', $retina = false)
 {
     global $wpdb, $blog_id;
     $query = "SELECT ID FROM {$wpdb->posts} WHERE guid='{$url}'";
     $id = $wpdb->get_var($query);
     $the_image_name = basename($url);
     if ($id == true && function_exists('mr_image_resize') && $url != NULL) {
         return mr_image_resize($url, $width, $height, $crop, $align, $retina);
     } else {
         if ($placeholder == true) {
             return 'http://placehold.it/' . $width . 'x' . $height;
         } else {
             return NULL;
         }
     }
 }
Ejemplo n.º 2
0
function zn_get_image($attachment_id = null, $width, $height = 0, $attr = array(), $popup = false)
{
    if (!$attachment_id) {
        return;
    }
    $html = '';
    $image = wp_get_attachment_image_src($attachment_id, 'full');
    if ($image) {
        //  print_z($image);
        $resized = mr_image_resize($image['0'], $width, $height, true, 'c', false);
        if (is_array($resized)) {
            $hwstring = image_hwstring($resized['width'], $resized['height']);
        } else {
            $hwstring = image_hwstring($width, $height);
            $resized = array('url' => $resized, 'width' => $width, 'height' => $height);
        }
        $attachment = get_post($attachment_id);
        $default_attr = array('src' => $resized['url'], 'class' => "img-responsive", 'alt' => trim(strip_tags(get_post_meta($attachment_id, '_wp_attachment_image_alt', true))));
        if (empty($default_attr['alt'])) {
            $default_attr['alt'] = trim(strip_tags($attachment->post_excerpt));
        }
        if (empty($default_attr['alt'])) {
            $default_attr['alt'] = trim(strip_tags($attachment->post_title));
        }
        $attr = wp_parse_args($attr, $default_attr);
        $attr = array_map('esc_attr', $attr);
        // ADD MAGNIFIC POPUP functionality
        if ($popup) {
            $attr['data-mfp-src'] = $image[0];
        }
        $html = rtrim("<img {$hwstring}");
        foreach ($attr as $name => $value) {
            $html .= " {$name}=" . '"' . $value . '"';
        }
        $html .= ' />';
    }
    return $html;
}
Ejemplo n.º 3
0
function theme_thumb($url, $width, $height = 0, $align = '', $retina = false)
{
    return mr_image_resize($url, $width, $height, true, $align, $retina);
}
Ejemplo n.º 4
0
function get_post_thumb($post_id, $width, $height, $custom = "image", $file = false, $original = false, $retina = false)
{
    //universal thumb function
    $show_no_image = get_option(THEME_NAME . "_show_no_image_thumb");
    if ($post_id != false) {
        $custom_image = get_post_custom_values($custom, $post_id);
        //get custom field value
        $custom_image = $custom_image[0];
    } else {
        $custom_image = false;
    }
    $upload_dir = wp_upload_dir();
    if ($custom_image != false && $custom != "image" && $file == false) {
        $src = array();
        $custom = THEME_NAME . "_homepage_image";
        $custom_image = get_post_custom_values($custom, $post_id);
        //get custom field value
        $src['url'] = $custom_image[0];
    }
    $meta = get_post_meta($post_id, "_thumbnail_id", true);
    //get wordpress built in thumbnail value
    $first_from_post = get_first_image($post_id);
    //get first image form post
    if ($custom_image && $custom == THEME_NAME . "_homepage_image" && $file == false) {
        //built in thumb
        $custom = THEME_NAME . "_homepage_image";
        $custom_image = get_post_custom_values($custom, $post_id);
        //get custom field value
        $file = $custom_image[0];
        $src = array();
        if ($original == false) {
            $src['url'] = mr_image_resize($file, $width, $height, true, '', $retina);
        } else {
            $src['url'] = $file;
        }
        $show_image = true;
    } elseif (get_the_post_thumbnail($post_id) != '' && $meta && $file == false) {
        //built in thumb
        $file = $upload_dir["baseurl"] . "/" . get_post_meta($meta, "_wp_attached_file", true);
        $src = array();
        if ($original == false) {
            $src['url'] = mr_image_resize($file, $width, $height, true, '', $retina);
        } else {
            $src['url'] = $file;
        }
        $show_image = true;
    } elseif ($first_from_post != false && $custom != THEME_NAME . "_homepage_image" && !get_the_post_thumbnail($post_id) && $file == false) {
        //first attached image
        $file = $first_from_post;
        if (strpos($file, "wp-content") !== false) {
            $pos = strpos($file, "/wp-content");
            $file = substr($file, $pos);
        }
        $src = array();
        if ($original == false) {
            $src['url'] = mr_image_resize(site_url() . $file, $width, $height, true, '', $retina);
        } else {
            $src['url'] = $file;
        }
        $show_image = true;
    } elseif ($file != false) {
        $src['url'] = mr_image_resize($file, $width, $height, true, '', $retina);
        $show_image = true;
    } else {
        //no image
        $src['url'] = get_template_directory_uri() . '/images/no-image-' . $width . 'x' . $height . '.jpg';
        if ($show_no_image == "on") {
            $show_image = true;
        } else {
            $show_image = false;
        }
    }
    return array("src" => $src['url'], "show" => $show_image);
}
 /**
  * @param null $attach_id
  * @param null $img_url
  * @param int $width
  * @param int $height
  * @param bool $crop
  *
  * @return array
  */
 function vt_resize($attach_id = null, $img_url = null, $width = 0, $height = 0, $crop = false)
 {
     if ($attach_id) {
         $img_url = wp_get_attachment_url($attach_id);
     }
     $image = mr_image_resize($img_url, $width, $height, true, 'c', false);
     if (is_array($image) && !empty($image['url'])) {
         return $image;
     } else {
         return array('url' => $img_url, 'width' => $width, 'height' => $height);
     }
 }
Ejemplo n.º 6
0
function shortcode_latest_news_container($atts, $content = null, $code)
{
    extract(shortcode_atts(array('type' => 'slider', 'items_per_column' => 1, 'number_of_posts' => 10, 'category' => '', 'align' => 'center', 'width' => '100%'), $atts));
    $i = 1;
    wp_reset_postdata();
    $args = array('posts_per_page' => $number_of_posts, 'post_status' => 'publish', 'category' => $category, 'orderby' => 'date');
    $output = '';
    $news_array = new WP_Query($args);
    if ($news_array->have_posts()) {
        $output .= '<div id="latest-news-products" class="latest-news-content" style="width:' . $width . '">';
        if ($type == "slider") {
            $output .= '<div id="' . $items_per_column . '_latest_news_carousel" class="latest-news-carousel">';
        } else {
            $output .= '<div id="latest_news_grid" class="latest-news-grid latest-news-cols-' . $items_per_column . '">';
        }
        while ($news_array->have_posts()) {
            $news_array->the_post();
            if ($i % $items_per_column == 1) {
                $class = " first";
            } elseif ($i % $items_per_column == 0) {
                $class = " last";
            } else {
                $class = "";
            }
            if (has_post_thumbnail() && !post_password_required()) {
                $post_thumbnail_id = get_post_thumbnail_id();
                $image = wp_get_attachment_url($post_thumbnail_id);
            } else {
                $image = get_template_directory_uri() . "/images/placeholders/placeholder.jpg";
            }
            $src = mr_image_resize($image, 150, 150, true, 't', false);
            if (empty($src) || $src == 'image_not_specified') {
                $src = get_template_directory_uri() . "/images/megnor/placeholder.png";
                $src = mr_image_resize($src, 150, 150, true, 't', false);
            }
            $output .= '<div class="item single-post-container' . $class . ' ' . $align . '">';
            $output .= '<div class="single-post">';
            $output .= '<div class="post-image">';
            $output .= '<img src="' . $src . '" title="' . get_the_title() . '" alt="' . get_the_title() . '" />';
            $output .= '<div class="post-image-hover"></div>';
            $output .= '<a href="' . $image . '" data-lightbox="example-set" class="icon zoom"></a>';
            $output .= '</div>';
            $shorttitle = substr(get_the_title('', '', FALSE), 0, 50);
            $output .= '<div class="post-title"><a href="' . get_permalink() . '" title="' . get_the_title() . '">' . $shorttitle . '</a></div>';
            $output .= '<div class="post-description">' . templatemela_blog_post_excerpt(25) . '</div>';
            $output .= '<div class="post-date">' . date("j M, Y", strtotime(get_the_date())) . '</div>';
            $output .= '</div></div>';
            $i++;
        }
        wp_reset_postdata();
        $output .= '</div></div>';
    } else {
        $output .= '<div class="no-result">No results found...</div>';
    }
    return $output;
}
Ejemplo n.º 7
0
 function veuse_retina_interchange_image($img_url, $width, $height, $crop)
 {
     $imagepath = '<img src="' . mr_image_resize($img_url, $width, $height, $crop, 'c', false) . '" data-interchange="[' . mr_image_resize($img_url, $width, $height, $crop, 'c', true) . ', (retina)]" alt=""/>';
     return $imagepath;
 }
function zl_theme_thumb($url, $width, $height = 0, $align = '')
{
    return mr_image_resize($url, $width, $height, true, $align, false);
}
Ejemplo n.º 9
0
function cshero_intro_list_render($params, $content = null)
{
    global $post, $wp_query;
    extract(shortcode_atts(array('category' => '1', 'excerpt_length' => '', 'crop_big' => '', 'big_width' => '465', 'big_height' => '340', 'crop_mini' => '', 'mini_width' => '465', 'mini_height' => '170', 'orderby' => 'ID', 'order' => 'DESC'), $params));
    wp_enqueue_style('introlist', get_template_directory_uri() . '/framework/shortcodes/introlist/css/introlist.css', array(), '1.0.0');
    if (isset($category) && $category != '') {
        $cats = explode(',', $category);
        $category = array();
        foreach ((array) $cats as $cat) {
            $category[] = trim($cat);
        }
        $args = array('posts_per_page' => 4, 'tax_query' => array(array('taxonomy' => 'category', 'field' => 'id', 'terms' => $category)), 'orderby' => $orderby, 'order' => $order, 'post_type' => 'post', 'post_status' => 'publish');
    } else {
        $args = array('posts_per_page' => 4, 'orderby' => $orderby, 'order' => $order, 'post_type' => 'post', 'post_status' => 'publish');
    }
    $wp_query = new WP_Query($args);
    $i = 0;
    ob_start();
    ?>

    <div class="cs-introlist">
    <?php 
    while ($wp_query->have_posts()) {
        $wp_query->the_post();
        $i++;
        ?>

        <?php 
        if ($i == 1 || $i == 3) {
            ?>

        <div class="col-xs-12 col-sm-6 col-md-6 col-lg-6">
        <?php 
        }
        ?>

            <?php 
        if ($i == 1 || $i == 4) {
            ?>

            <?php 
            $attachment_image = "";
            if (has_post_thumbnail()) {
                $image = wp_get_attachment_image_src(get_post_thumbnail_id(get_the_ID()), 'full', false);
                if ($crop_big) {
                    $attachment_image = mr_image_resize($image[0], $big_width, $big_height, true, 'c', false);
                } else {
                    $attachment_image = $image[0];
                }
            }
            ?>

            <div class="cs-introlist-big">
                <div class="cs-introlist-image">
                    <img alt="<?php 
            the_title();
            ?>
" src="<?php 
            echo esc_url($attachment_image);
            ?>
">
                    <div class="cs-introlist-description">
                        <?php 
            if ($excerpt_length != '') {
                echo cshero_string_limit_words(strip_tags(get_the_content()), (int) $excerpt_length);
            } else {
                echo strip_tags(get_the_content());
            }
            ?>

                    </div>
                    <div class="cs-introlist-title">
                        <h3><a href="<?php 
            the_permalink();
            ?>
"><?php 
            the_title();
            ?>
</a></h3>
                    </div>
                    <div class="cs-introlist-more"><a href="<?php 
            the_permalink();
            ?>
"><?php 
            _e('More Info', THEMENAME);
            ?>
</a></div>
                    <a class="cs-introlist-overlay" href="<?php 
            the_permalink();
            ?>
"></a>
                </div>
            </div>
            <?php 
        }
        ?>

            <?php 
        if ($i == 2 || $i == 3) {
            ?>

            <?php 
            $attachment_image = "";
            if (has_post_thumbnail()) {
                $image = wp_get_attachment_image_src(get_post_thumbnail_id(get_the_ID()), 'full', false);
                if ($crop_mini) {
                    $attachment_image = mr_image_resize($image[0], $mini_width, $mini_height, true, 'c', false);
                } else {
                    $attachment_image = $image[0];
                }
            }
            ?>

            <div class="cs-introlist-mini">
                <div class="cs-introlist-image">
                    <img alt="<?php 
            the_title();
            ?>
" src="<?php 
            echo esc_url($attachment_image);
            ?>
">
                    <div class="cs-introlist-title">
                        <h3><a href="<?php 
            the_permalink();
            ?>
"><?php 
            the_title();
            ?>
</a></h3>
                    </div>
                    <div class="cs-introlist-more"><a href="<?php 
            the_permalink();
            ?>
"><?php 
            _e('More Info', THEMENAME);
            ?>
</a></div>
                    <a class="cs-introlist-overlay" href="<?php 
            the_permalink();
            ?>
"></a>
                </div>
            </div>
            <?php 
        }
        ?>

        <?php 
        if ($i == 2 || $i == 4) {
            ?>

        </div>
        <?php 
        }
        ?>

    <?php 
    }
    ?>

    </div>
    <?php 
    wp_reset_query();
    wp_reset_postdata();
    return ob_get_clean();
}
					</div>
				</div>
				<div class="clear"></div>
			</div>
			<div class="clear"></div>
			<div class="zl_copyright">
				<div class="row">
					<div class="large-6 ">
						<?php 
echo zl_option('footer_copyright');
?>
					</div>
					<div class="large-6  text-right">
						<?php 
$logo = zl_option('logo_footer');
$logo = mr_image_resize($logo, 100, null, false, 'c', false);
if ($logo) {
    ?>
							 <a href="<?php 
    echo esc_url(home_url('/'));
    ?>
"><img class="zl_logo" src="<?php 
    echo $logo;
    ?>
" alt="<?php 
    bloginfo('title');
    ?>
"/></a>
						<?php 
}
?>
Ejemplo n.º 11
0
function templatemela_print_images_thumb($src, $alttext, $width = 200, $height = 200, $align = 'left')
{
    $src = mr_image_resize($src, $width, $height, true, $align, false);
    if (empty($src) || $src == 'image_not_specified') {
        $src = get_template_directory_uri() . "/images/megnor/placeholder.png";
        $src = mr_image_resize($src, $width, $height, true, $align, false);
    }
    $return = '';
    $return .= '<img src="' . $src . '"';
    $return .= " title='{$alttext}' alt='{$alttext}' width='{$width}' height='{$height}' />";
    echo $return;
}
Ejemplo n.º 12
0
 function tally_image($url, $width = '', $height = '', $crop = true, $placeholder = true, $align = '', $retina = TALLY_IMAGE_RETINA_SUPPORT)
 {
     global $wpdb, $blog_id;
     $query = "SELECT ID FROM {$wpdb->posts} WHERE guid='{$url}'";
     $id = $wpdb->get_var($query);
     $the_image_name = basename($url);
     if ($id == true && function_exists('mr_image_resize') && $url != NULL) {
         return mr_image_resize($url, $width, $height, $crop, $align, $retina);
     } elseif (file_exists(get_stylesheet_directory() . '/images/demo/' . $the_image_name) && function_exists('mr_image_resize') && $url != NULL) {
         list($or_width, $or_height) = getimagesize(get_template_directory() . '/images/demo/' . $the_image_name);
         if ($or_width == $width && $or_height == $height) {
             return get_template_directory_uri() . '/images/demo/' . $the_image_name;
         } else {
             return mr_image_resize(get_template_directory_uri() . '/images/demo/' . $the_image_name, $width, $height, $crop, $align, $retina);
         }
     } elseif (file_exists(get_template_directory() . '/images/demo/' . $the_image_name) && function_exists('mr_image_resize') && $url != NULL) {
         list($or_width, $or_height) = getimagesize(get_template_directory() . '/images/demo/' . $the_image_name);
         if ($or_width == $width && $or_height == $height) {
             return get_template_directory_uri() . '/images/demo/' . $the_image_name;
         } else {
             return mr_image_resize(get_template_directory_uri() . '/images/demo/' . $the_image_name, $width, $height, $crop, $align, $retina);
         }
     } else {
         return 'http://placehold.it/' . $width . 'x' . $height;
     }
 }