function widget($args, $instance) { extract($args); $title = apply_filters('widget_title', empty($instance['title']) ? 'About Me' : $instance['title']); $imagePath = empty($instance['imagePath']) ? '' : $instance['imagePath']; $aboutText = empty($instance['aboutText']) ? '' : $instance['aboutText']; echo $before_widget; if ($title) { echo $before_title . $title . $after_title; } ?> <div class="clearfix"> <img src="<?php bloginfo('template_directory'); ?> /timthumb.php?src=<?php echo et_multisite_thumbnail($imagePath); ?> &h=74&w=74&zc=1" id="about-image" alt="about us image" /> <p><?php echo $aboutText; ?> </p> </div> <!-- end about me section --> <?php echo $after_widget; }
function insertThumbnailRSS($content) { global $post; $thumb = ''; $thumb = get_post_meta($post->ID, 'Thumbnail', true); if (has_post_thumbnail($post->ID)) { $content = '<p>' . get_the_post_thumbnail($post->ID, 'medium') . '</p>' . $content; } else { if ($thumb != '') { $content = '<p>' . '<img src="' . et_new_thumb_resize(et_multisite_thumbnail($thumb), 300, 200, '', true) . '"/>' . '</p>' . $content; } } return $content; }
function widget($args, $instance) { extract($args); $logoImagePath = empty($instance['logoImagePath']) ? '' : esc_url($instance['logoImagePath']); $copyrightInfo = empty($instance['copyrightInfo']) ? '' : esc_attr($instance['copyrightInfo']); $imagePath = empty($instance['imagePath']) ? '' : esc_url($instance['imagePath']); $textInfo = empty($instance['textInfo']) ? '' : esc_attr($instance['textInfo']); $readMoreUrl = empty($instance['readMoreUrl']) ? '' : esc_url($instance['readMoreUrl']); $readMoreText = empty($instance['readMoreText']) ? '' : esc_attr($instance['readMoreText']); echo $before_widget; ?> <p id="footer-logo"><img alt="" src="<?php echo $logoImagePath; ?> " /><span><?php echo $copyrightInfo; ?> </span></p> <div class="thumb"> <img class="item-image" alt="" src="<?php echo et_new_thumb_resize(et_multisite_thumbnail($imagePath), 56, 56, '', true); ?> " /> <span class="overlay"></span> </div> <p><?php echo $textInfo; ?> </p> <a class="readmore" href="<?php echo $readMoreUrl; ?> "><span><?php echo $readMoreText; ?> </span></a> <?php echo $after_widget; }
function widget($args, $instance) { extract($args); $title = apply_filters('widget_title', empty($instance['title']) ? 'About Me' : esc_html($instance['title'])); $imagePath = empty($instance['imagePath']) ? '' : esc_url($instance['imagePath']); $aboutText = empty($instance['aboutText']) ? '' : $instance['aboutText']; echo $before_widget; if ($title) { echo $before_title . $title . $after_title; } ?> <div class="clearfix"> <img src="<?php echo et_new_thumb_resize(et_multisite_thumbnail($imagePath), 74, 74, '', true); ?> " id="about-image" alt="" /> <?php echo wp_kses_post($aboutText); ?> </div> <!-- end about me section --> <?php echo $after_widget; }
function et_resize_image($thumb, $new_width, $new_height, $crop) { if (is_ssl()) { $thumb = preg_replace('#^http://#', 'https://', $thumb); } $info = pathinfo($thumb); $ext = $info['extension']; $name = wp_basename($thumb, ".{$ext}"); $is_jpeg = false; $site_uri = apply_filters('et_resize_image_site_uri', site_url()); $site_dir = apply_filters('et_resize_image_site_dir', ABSPATH); #get main site url on multisite installation if (is_multisite()) { switch_to_blog(1); $site_uri = site_url(); restore_current_blog(); } if ('jpeg' == $ext) { $ext = 'jpg'; $name = preg_replace('#.jpeg$#', '', $name); $is_jpeg = true; } $suffix = "{$new_width}x{$new_height}"; $destination_dir = '' != get_option('et_images_temp_folder') ? preg_replace('#\\/\\/#', '/', get_option('et_images_temp_folder')) : null; $matches = apply_filters('et_resize_image_site_dir', array(), $site_dir); if (!empty($matches)) { preg_match('#' . $matches[1] . '$#', $site_uri, $site_uri_matches); if (!empty($site_uri_matches)) { $site_uri = str_replace($matches[1], '', $site_uri); $site_uri = preg_replace('#/$#', '', $site_uri); $site_dir = str_replace($matches[1], '', $site_dir); $site_dir = preg_replace('#\\\\/$#', '', $site_dir); } } #get local name for use in file_exists() and get_imagesize() functions $localfile = str_replace(apply_filters('et_resize_image_localfile', $site_uri, $site_dir, et_multisite_thumbnail($thumb)), $site_dir, et_multisite_thumbnail($thumb)); $add_to_suffix = ''; if (file_exists($localfile)) { $add_to_suffix = filesize($localfile) . '_'; } #prepend image filesize to be able to use images with the same filename $suffix = $add_to_suffix . $suffix; $destfilename_attributes = '-' . $suffix . '.' . $ext; $checkfilename = '' != $destination_dir && null !== $destination_dir ? path_join($destination_dir, $name) : path_join(dirname($localfile), $name); $checkfilename .= $destfilename_attributes; if ($is_jpeg) { $checkfilename = preg_replace('#.jpeg$#', '.jpg', $checkfilename); } $uploads_dir = wp_upload_dir(); $uploads_dir['basedir'] = preg_replace('#\\/\\/#', '/', $uploads_dir['basedir']); if (null !== $destination_dir && '' != $destination_dir && apply_filters('et_enable_uploads_detection', true)) { $site_dir = trailingslashit(preg_replace('#\\/\\/#', '/', $uploads_dir['basedir'])); $site_uri = trailingslashit($uploads_dir['baseurl']); } #check if we have an image with specified width and height if (file_exists($checkfilename)) { return str_replace($site_dir, trailingslashit($site_uri), $checkfilename); } $size = @getimagesize($localfile); if (!$size) { return new WP_Error('invalid_image_path', __('Image doesn\'t exist'), $thumb); } list($orig_width, $orig_height, $orig_type) = $size; #check if we're resizing the image to smaller dimensions if ($orig_width > $new_width || $orig_height > $new_height) { if ($orig_width < $new_width || $orig_height < $new_height) { #don't resize image if new dimensions > than its original ones if ($orig_width < $new_width) { $new_width = $orig_width; } if ($orig_height < $new_height) { $new_height = $orig_height; } #regenerate suffix and appended attributes in case we changed new width or new height dimensions $suffix = "{$add_to_suffix}{$new_width}x{$new_height}"; $destfilename_attributes = '-' . $suffix . '.' . $ext; $checkfilename = '' != $destination_dir && null !== $destination_dir ? path_join($destination_dir, $name) : path_join(dirname($localfile), $name); $checkfilename .= $destfilename_attributes; #check if we have an image with new calculated width and height parameters if (file_exists($checkfilename)) { return str_replace($site_dir, trailingslashit($site_uri), $checkfilename); } } #we didn't find the image in cache, resizing is done here $result = image_resize($localfile, $new_width, $new_height, $crop, $suffix, $destination_dir); if (!is_wp_error($result)) { #transform local image path into URI if ($is_jpeg) { $thumb = preg_replace('#.jpeg$#', '.jpg', $thumb); } $site_dir = str_replace('\\', '/', $site_dir); $result = str_replace('\\', '/', $result); $result = str_replace('//', '/', $result); $result = str_replace($site_dir, trailingslashit($site_uri), $result); } #returns resized image path or WP_Error ( if something went wrong during resizing ) return $result; } #returns unmodified image, for example in case if the user is trying to resize 800x600px to 1920x1080px image return $thumb; }
function et_resize_image($thumb, $new_width, $new_height, $crop) { /* * Fixes the issue with x symbol between width and height values in the filename. * For instance, sports-400x400.jpg file results in 'image not found' in getimagesize() function. */ $thumb = str_replace('%26%23215%3B', 'x', rawurlencode($thumb)); $thumb = rawurldecode($thumb); if (is_ssl()) { $thumb = preg_replace('#^http://#', 'https://', $thumb); } $info = pathinfo($thumb); $ext = $info['extension']; $name = wp_basename($thumb, ".{$ext}"); $is_jpeg = false; $site_uri = apply_filters('et_resize_image_site_uri', site_url()); $site_dir = apply_filters('et_resize_image_site_dir', ABSPATH); // If multisite, not the main site, WordPress version < 3.5 or ms-files rewriting is enabled ( not the fresh WordPress installation, updated from the 3.4 version ) if (is_multisite() && !is_main_site() && (!function_exists('wp_get_mime_types') || get_site_option('ms_files_rewriting'))) { //Get main site url on multisite installation switch_to_blog(1); $site_uri = site_url(); restore_current_blog(); } /* * If we're dealing with an external image ( might be the result of Grab the first image function ), * return original image url */ if (false === strpos($thumb, $site_uri)) { return $thumb; } if ('jpeg' == $ext) { $ext = 'jpg'; $name = preg_replace('#.jpeg$#', '', $name); $is_jpeg = true; } $suffix = "{$new_width}x{$new_height}"; $destination_dir = '' != get_option('et_images_temp_folder') ? preg_replace('#\\/\\/#', '/', get_option('et_images_temp_folder')) : null; $matches = apply_filters('et_resize_image_site_dir', array(), $site_dir); if (!empty($matches)) { preg_match('#' . $matches[1] . '$#', $site_uri, $site_uri_matches); if (!empty($site_uri_matches)) { $site_uri = str_replace($matches[1], '', $site_uri); $site_uri = preg_replace('#/$#', '', $site_uri); $site_dir = str_replace($matches[1], '', $site_dir); $site_dir = preg_replace('#\\\\/$#', '', $site_dir); } } #get local name for use in file_exists() and get_imagesize() functions $localfile = str_replace(apply_filters('et_resize_image_localfile', $site_uri, $site_dir, et_multisite_thumbnail($thumb)), $site_dir, et_multisite_thumbnail($thumb)); $add_to_suffix = ''; if (file_exists($localfile)) { $add_to_suffix = filesize($localfile) . '_'; } #prepend image filesize to be able to use images with the same filename $suffix = $add_to_suffix . $suffix; $destfilename_attributes = '-' . $suffix . '.' . strtolower($ext); $checkfilename = '' != $destination_dir && null !== $destination_dir ? path_join($destination_dir, $name) : path_join(dirname($localfile), $name); $checkfilename .= $destfilename_attributes; if ($is_jpeg) { $checkfilename = preg_replace('#.jpg$#', '.jpeg', $checkfilename); } $uploads_dir = wp_upload_dir(); $uploads_dir['basedir'] = preg_replace('#\\/\\/#', '/', $uploads_dir['basedir']); if (null !== $destination_dir && '' != $destination_dir && apply_filters('et_enable_uploads_detection', true)) { $site_dir = trailingslashit(preg_replace('#\\/\\/#', '/', $uploads_dir['basedir'])); $site_uri = trailingslashit($uploads_dir['baseurl']); } #check if we have an image with specified width and height if (file_exists($checkfilename)) { return str_replace($site_dir, trailingslashit($site_uri), $checkfilename); } $size = @getimagesize($localfile); if (!$size) { return new WP_Error('invalid_image_path', __('Image doesn\'t exist'), $thumb); } list($orig_width, $orig_height, $orig_type) = $size; #check if we're resizing the image to smaller dimensions if ($orig_width > $new_width || $orig_height > $new_height) { if ($orig_width < $new_width || $orig_height < $new_height) { #don't resize image if new dimensions > than its original ones if ($orig_width < $new_width) { $new_width = $orig_width; } if ($orig_height < $new_height) { $new_height = $orig_height; } #regenerate suffix and appended attributes in case we changed new width or new height dimensions $suffix = "{$add_to_suffix}{$new_width}x{$new_height}"; $destfilename_attributes = '-' . $suffix . '.' . $ext; $checkfilename = '' != $destination_dir && null !== $destination_dir ? path_join($destination_dir, $name) : path_join(dirname($localfile), $name); $checkfilename .= $destfilename_attributes; #check if we have an image with new calculated width and height parameters if (file_exists($checkfilename)) { return str_replace($site_dir, trailingslashit($site_uri), $checkfilename); } } #we didn't find the image in cache, resizing is done here if (!function_exists('wp_get_image_editor')) { // compatibility with versions of WordPress prior to 3.5. $result = image_resize($localfile, $new_width, $new_height, $crop, $suffix, $destination_dir); } else { $et_image_editor = wp_get_image_editor($localfile); if (!is_wp_error($et_image_editor)) { $et_image_editor->resize($new_width, $new_height, $crop); // generate correct file name/path $et_new_image_name = $et_image_editor->generate_filename($suffix, $destination_dir); do_action('et_resize_image_before_save', $et_image_editor, $et_new_image_name); $et_image_editor->save($et_new_image_name); // assign new image path $result = $et_new_image_name; } else { // assign a WP_ERROR ( WP_Image_Editor instance wasn't created properly ) $result = $et_image_editor; } } if (!is_wp_error($result)) { // transform local image path into URI if ($is_jpeg) { $thumb = preg_replace('#.jpeg$#', '.jpg', $thumb); } $site_dir = str_replace('\\', '/', $site_dir); $result = str_replace('\\', '/', $result); $result = str_replace('//', '/', $result); $result = str_replace($site_dir, trailingslashit($site_uri), $result); } #returns resized image path or WP_Error ( if something went wrong during resizing ) return $result; } #returns unmodified image, for example in case if the user is trying to resize 800x600px to 1920x1080px image return $thumb; }
</h1> <?php $media = get_post_meta($post->ID, '_et_used_images', true); $width = apply_filters('et_single_project_width', 960); $height = apply_filters('et_single_project_height', 480); $titletext = get_the_title(); if ($media) { echo '<div class="flexslider"><ul class="slides">'; foreach ((array) $media as $et_media) { echo '<li class="slide">'; if (is_numeric($et_media)) { $et_fullimage_array = wp_get_attachment_image_src($et_media, 'full'); if ($et_fullimage_array) { $et_fullimage = $et_fullimage_array[0]; echo '<img src="' . esc_url(et_new_thumb_resize(et_multisite_thumbnail($et_fullimage), $width, $height, '', true)) . '" width="' . esc_attr($width) . '" height="' . esc_attr($height) . '" alt="' . esc_attr($titletext) . '" />'; } } else { $video_embed = $wp_embed->shortcode('', esc_url($et_media)); $video_embed = preg_replace('/<embed /', '<embed wmode="transparent" ', $video_embed); $video_embed = preg_replace('/<\\/object>/', '<param name="wmode" value="transparent" /></object>', $video_embed); $video_embed = preg_replace("/height=\"[0-9]*\"/", "height={$height}", $video_embed); $video_embed = preg_replace("/width=\"[0-9]*\"/", "width={$width}", $video_embed); echo $video_embed; } echo '</li>'; } echo '</ul></div>'; } else { $thumb = ''; $classtext = 'single_project_image';
function et_show_ajax_project() { global $wp_embed; $project_id = (int) $_POST['et_project_id']; $portfolio_args = array('post_type' => 'project', 'p' => $project_id); $portfolio_query = new WP_Query(apply_filters('et_ajax_portfolio_args', $portfolio_args)); while ($portfolio_query->have_posts()) { $portfolio_query->the_post(); global $post; $width = (int) apply_filters('et_ajax_media_width', 600); $height = (int) apply_filters('et_ajax_media_height', 480); $titletext = get_the_title(); $media = get_post_meta(get_the_ID(), '_et_used_images', true); echo '<div class="et_media">'; if ($media) { echo '<div class="flexslider"><ul class="slides">'; foreach ((array) $media as $et_media) { echo '<li class="slide">'; if (is_numeric($et_media)) { $et_fullimage_array = wp_get_attachment_image_src($et_media, 'full'); if ($et_fullimage_array) { $et_fullimage = $et_fullimage_array[0]; echo '<img src="' . esc_attr(et_new_thumb_resize(et_multisite_thumbnail($et_fullimage), $width, $height, '', true)) . '" width="' . esc_attr($width) . '" height="' . esc_attr($height) . '" alt="' . esc_attr($titletext) . '" />'; } } else { $video_embed = apply_filters('the_content', $wp_embed->shortcode('', esc_url($et_media))); $video_embed = preg_replace('/<embed /', '<embed wmode="transparent" ', $video_embed); $video_embed = preg_replace('/<\\/object>/', '<param name="wmode" value="transparent" /></object>', $video_embed); $video_embed = preg_replace("/height=\"[0-9]*\"/", "height={$height}", $video_embed); $video_embed = preg_replace("/width=\"[0-9]*\"/", "width={$width}", $video_embed); echo $video_embed; } echo '</li>'; } echo '</ul></div>'; } else { $thumb = ''; $classtext = ''; $titletext = get_the_title(); $thumbnail = get_thumbnail($width, $height, $classtext, $titletext, $titletext, false, 'Ajaximage'); $thumb = $thumbnail["thumb"]; echo '<a href="' . esc_url(get_permalink()) . '">'; print_thumbnail($thumb, $thumbnail["use_timthumb"], $titletext, $width, $height, $classtext); echo '</a>'; } echo '</div> <!-- end .et_media -->'; echo '<div class="et_media_description">' . '<h2 class="title">' . '<a href="' . get_permalink() . '">' . get_the_title() . '</a>' . '</h2>' . truncate_post(560, false); echo '</div> <!-- end .et_media_description -->'; echo '<a class="more" href="' . get_permalink() . '">' . __('More info »', 'Flexible') . '</a>'; } wp_reset_postdata(); die; }
} if (is_page()) { $et_used_images = get_post_meta(get_the_ID(), '_et_used_images', true); } if ('' != $bg_image || $et_used_images) { if ('' != $bg_image) { echo '<li> <img src="' . esc_attr($bg_image) . '" alt="" /> </li>'; } else { foreach ($et_used_images as $et_attachment_id => $et_used_image) { $et_fullimage_array = wp_get_attachment_image_src($et_attachment_id, 'full'); if ($et_fullimage_array) { $et_fullimage = $et_fullimage_array[0]; echo '<li> <img src="' . esc_attr($et_fullimage) . '" data-smallimage="' . esc_attr(et_new_thumb_resize(et_multisite_thumbnail($et_fullimage), 43, 43, '', true)) . '" data-image_title="' . esc_attr($et_used_image['image_title']) . '" data-image_desc="' . esc_attr($et_used_image['image_description']) . '" alt="" /> </li>'; } } } } echo '</ul>'; ?> <div id="pattern_overlay"></div> <?php wp_footer(); ?> </div> <!-- #wrapper --> </body>
for ($i = 0; $i <= count($custom["thumbs"]) - 1; $i++) { ?> <a href="#" <?php if ($i == 0) { echo 'class="active"'; } if ($i == count($custom["thumbs"]) - 1) { echo 'class="last"'; } ?> rel="<?php echo $i + 1; ?> "> <?php echo et_new_thumb_resize(et_multisite_thumbnail($custom["thumbs"][$i]), 69, 69); ?> <span class="overlay"></span> </a> <?php } ?> </div> <!-- #product-thumbs --> <?php } ?> </div> <!-- #product-slider --> <?php } ?>
function et_new_lb_image($atts, $content = null) { extract(shortcode_atts(array('image_url' => '', 'imagesize' => '', 'image_title' => '', 'image_alt' => ''), $atts)); $attributes = et_lb_get_attributes($atts, "et_lb_image"); if ('' != $imagesize) { $image_size = explode('x', $imagesize); $image_size = array_map('intval', $image_size); } $image = '' != $image_url && '' == $imagesize ? $image_url : et_new_thumb_resize(et_multisite_thumbnail($image_url), $image_size[0], $image_size[1], '', true); if ('' != $image) { $image = sprintf('<img alt="%1$s" src="%2$s" title="%3$s" />', esc_attr($image_alt), esc_attr($image), esc_attr($image_title)); } $output = "<div {$attributes['class']}{$attributes['inline_styles']}>\n\t\t\t\t\t<div class='et_lb_module_content'>\n\t\t\t\t\t\t<div class='et_lb_module_content_inner clearfix'>" . ('' != $image ? '<div class="et_lb_image_box">' . "<a href='" . esc_url($image_url) . "' class='fancybox' title='" . esc_attr($image_title) . "'>{$image}<span class='et_lb_zoom_icon'></span></a>" . '</div>' : '') . ('' != trim($content) ? '<div class="et_lb_image_content">' . do_shortcode(et_lb_fix_shortcodes($content)) . '</div> <!-- end .et_lb_image_content -->' : '') . "\t\t</div> <!-- end .et_lb_module_content_inner -->\n\t\t\t\t\t</div> <!-- end .et_lb_module_content -->\n\t\t\t\t</div> <!-- end .et_lb_widget_area -->"; et_new_load_convertible_scripts(array('image')); return $output; }
function print_thumbnail($thumbnail = '', $use_timthumb = true, $alttext = '', $width = 100, $height = 100, $class = '', $echoout = true, $forstyle = false, $resize = true, $post = '') { if ($post == '') { global $post; } $output = ''; $thumbnail_orig = $thumbnail; $thumbnail = et_multisite_thumbnail($thumbnail); $cropPosition = get_post_meta($post->ID, 'etcrop', true) ? get_post_meta($post->ID, 'etcrop', true) : ''; if ($cropPosition != '') { $cropPosition = '&a=' . $cropPosition; } if ($forstyle === false) { if ($use_timthumb === false) { $output = $thumbnail_orig; } else { $output = '<img src="' . get_bloginfo('template_directory') . '/timthumb.php?src=' . $thumbnail . '&h=' . $height . '&w=' . $width . '&zc=1&q=90' . $cropPosition . '"'; if ($class != '') { $output .= " class='{$class}' "; } $output .= " alt='{$alttext}' width='{$width}' height='{$height}' />"; if (!$resize) { $output = $thumbnail; } } } else { $output = $thumbnail; if ($use_timthumb === false) { $output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $output, $matches); $output = $matches[1][0]; } else { $output = get_bloginfo('template_directory') . '/timthumb.php?src=' . $output . '&h=' . $height . '&w=' . $width . '&q=90&zc=1' . $cropPosition; } } if ($echoout) { echo $output; } else { return $output; } }