function wpthumb_img_shortcode($args) { $args_attrs = array('class', 'alt'); $attrs = array(); foreach ($args_attrs as $att) { if (isset($args[$att])) { $attrs[$att] = $args[$att]; unset($args[$att]); } } if (is_numeric($args[0])) { $attachment_id = $args[0]; unset($args[0]); return wp_get_attachment_image($attachment_id, $args, false, $attrs); } else { if (!empty($args)) { $url = esc_url($args[0]); unset($args[0]); $image = wpthumb($url, $args); list($width, $height) = getimagesize($image); $attr = ''; foreach ($attrs as $a => $value) { $attr .= ' ' . $a . '="' . esc_attr($value) . '"'; } return '<img src="' . $image . '" width="' . $width . '" height="' . $height . '"' . $attr . ' />'; } } }
function get_avatar($size) { if (!hma_get_avatar_upload_path($this->user)) { return null; } return wpthumb(hma_get_avatar_upload_path($this->user), $size); }
function justified_infinite_scroll_foogallery_attachment_resize_thumbnail($original_image_src, $args, $thumbnail_object) { // Some defaults for the dynamic generation... $arg_defaults = array('thumb_size' => 'large', 'width' => 0, 'height' => 0, 'jpeg_quality' => intval(foogallery_get_setting('thumb_jpeg_quality')), 'thumb_resize_animations' => foogallery_get_setting('thumb_resize_animations')); $args = wp_parse_args($args, $arg_defaults); $thumb_size = $args['thumb_size']; if ($thumb_size != 'dynamic') { //check if we are going to use the thumbnails that we already have //check to make sure we have a valid ID, else return the original image if ($thumbnail_object->ID > 0) { $thumbnail_attributes = wp_get_attachment_image_src($thumbnail_object->ID, $thumb_size); return $thumbnail_attributes[0]; } else { return $original_image_src; } } else { // To do dynamic generation, we need either a width or a height. //If nothing is given then default to the thumb width setting in Settings->Media $width = (int) $args['width']; $height = (int) $args['height']; if (0 == $width && 0 == $height) { $args['width'] = (int) get_option('thumbnail_size_w'); } return wpthumb($original_image_src, $args); } }
function _show_watermark_on_image_downsize($return, $id, $size) { $options = wpthumb_wm_get_options($id); $options['pre_resize'] = true; if (is_array($size) && key($size) === 0) { $size = array('width' => $size[0], 'height' => $size[1]); } else { $size = wp_parse_args($size); } $size['watermark_options'] = $options; return array(wpthumb(get_attached_file($id), $size)); }
function testmakeImageGreyScale() { add_filter('wspthumb_image_post', function (WP_Image_Editor $editor, $args) { if (!is_a($editor, 'WP_Image_Editor_GD') || empty($args['greyscale'])) { return $editor; } imagefilter($editor->get_image(), IMG_FILTER_GRAYSCALE); return $editor; }, 10, 2); $path = dirname(__FILE__) . '/images/google.png'; error_log(wpthumb('http://hm-base.local/content/uploads/2013/01/ed6d35fe-5a9b-11e2-847b-fbb7185f3122.png', 'width=150&height=150&greyscale=1')); }
function crb_modify_gallery_shortcote_markup($content) { // fix WP gallery image sizes $pattern = "/<dt\\s*class='gallery-icon[^']*'\\s*>\\s*<a[^>]*href='([^']*)'>\\s*(<img[^>]+>)\\s*<\\/a>\\s*<\\/dt>/"; preg_match_all($pattern, $content, $gallery_items); foreach ($gallery_items[0] as $index => $gallery_item_html) { $full_image_url = $gallery_items[1][$index]; $image_html = $gallery_items[2][$index]; # http://andrew.hedges.name/experiments/aspect_ratio/ # required size : 165 x 114, cropped size : 500 x 345 pixels # aspect ratio 55 : 38 $new_image_html = '<img class="attachment-thumbnail" src="' . wpthumb($full_image_url, 500, 345) . '" alt="" />'; $new_gallery_item_html = str_replace($image_html, $new_image_html, $gallery_item_html); # update new markup $content = str_replace($gallery_item_html, $new_gallery_item_html, $content); } return $content; }
function resize($original_image_src, $args, $thumbnail_object) { $arg_defaults = array('width' => 0, 'height' => 0, 'crop' => true, 'jpeg_quality' => foogallery_thumbnail_jpeg_quality(), 'thumb_resize_animations' => foogallery_get_setting('thumb_resize_animations')); $args = wp_parse_args($args, $arg_defaults); $width = (int) $args['width']; $height = (int) $args['height']; $crop = (bool) $args['crop']; //check if we are trying to get back the default thumbnail that we already have if ($thumbnail_object->ID > 0 && $width == get_option('thumbnail_size_w') && $height == get_option('thumbnail_size_h') && $crop == get_option('thumbnail_crop')) { $thumbnail_attributes = wp_get_attachment_image_src($thumbnail_object->ID); return $thumbnail_attributes[0]; } //we need either a width or a height. If nothing is given then default to the thumb width setting in Settings->Media if (0 == $width && 0 == $height) { $args['width'] = (int) get_option('thumbnail_size_w'); } return wpthumb($original_image_src, $args); }
protected function set_mask($image_width, $image_height, $required_width, $required_height) { $watermark_src = ''; $width_diff = 0; $height_diff = 0; if ($image_width > $required_width) { $width_diff = ($image_width - $required_width) * 100 / $image_width; } if ($image_height > $required_height) { $height_diff = ($image_height - $required_height) * 100 / $image_height; } if ($width_diff > 0 || $height_diff > 0) { $correction = max($width_diff, $height_diff); $new_image_width = $image_width - $correction / 100 * $image_width; $new_image_height = $image_height - $correction / 100 * $image_height; } else { $new_image_width = $image_width; $new_image_height = $image_height; } $watermark_new_size = min($new_image_width, $new_image_height) * ($this->scale_ratio / 100); $mask_src = wpthumb($watermark_src, array('width' => $watermark_new_size, 'height' => $watermark_new_size, 'crop' => false)); $this->args['mask'] = $mask_src; return $watermark_new_src; }
/** * hma_get_avatar_upload function. * * @param object $user * @param int $width * @param int $height * @param bool $crop * @return string */ function hma_get_avatar_upload($user, $width, $height, $crop) { if ($path = hma_get_avatar_upload_path($user)) { return wpthumb($path, $width, $height, $crop); } return ''; }
//Assign our Fields $title = get_the_title(); $effect = get_theme_mod('wf_hero_background_image_color'); $opacity = get_theme_mod('wf_hero_background_image_opacity', '0.5'); $style = get_theme_mod('wf_hero_header_style', 'box-brand-primary'); $post = $wp_query->post; $post_id = $post->ID; $post_object = get_post($post_id); //Images if (get_theme_mod('wf_hero_background_type', 'picture') == 'upload') { $image_url = get_theme_mod('wf_hero_background_image'); $image = wpthumb($image_url, 'width=1600&crop=0'); } elseif (get_theme_mod('wf_hero_background_type', 'picture') == 'picture') { $image_url = get_theme_mod('wf_hero_background_picture', WEFOSTER_HERO_BACKGROUND); $image = wpthumb($image_url, 'width=1600&crop=0'); } ?> <div class="wf-hero box-vertical-full margin-bottom-full <?php echo $style; ?> darken" style="min-height: <?php echo $height; ?> vh;"> <div class="wf-hero-background <?php echo $effect; ?> " style="background-image: url(<?php echo $image;
<div data-src="<?php echo $img_normal; ?> "></div> <div data-src="<?php echo $img_retina; ?> " data-media="(min-width: 768px) and (min-device-pixel-ratio: 2.0)"></div> <!-- mobile --> <div data-src="<?php echo wpthumb($img_normal, 'width=640&height=960&crop=1&crop_from_position=center,center'); ?> " data-media="(max-width: 767px)"></div> <div data-src="<?php echo wpthumb($img_retina, 'width=900&height=1600&crop=1&crop_from_position=center,center'); ?> " data-media="(max-width: 767px) and (min-device-pixel-ratio: 2.0)"></div> <!-- In IE8 the Slider cannot set the background image. This is a workaround --> <!--[if (lt IE 9) & (!IEMobile)]> <span data-src="<?php echo $img_normal; ?> "></span> <![endif]--> <noscript> <img src="<?php echo $img_normal; ?>
function x_banner_button($atts, $content) { ob_start(); if (has_post_thumbnail($post->ID)) { $image = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'single-post-thumbnail'); $thumb_img = get_post(get_post_thumbnail_id($post->ID)); $imagePath = $image[0]; } $output = '<div class="bannerText">'; $output .= '<div id="page-header" style="background-image: url(' . wpthumb($imagePath, 'width=1500&height=450&crop=1&resize=1') . ')">'; $output .= '<div class="container">'; $output .= '<div class="container pageheader">'; $output .= '<h2>' . get_the_title() . '</h2>'; $output .= '<div class="text-separator"></div>'; $output .= '<h4>'; if (is_plugin_active('secondary-title/secondary-title.php')) { //plugin is activated $output .= get_secondary_title(); } $output .= '</h4>'; $output .= '</div>'; $settings = get_option("lowestroomavailable"); $var1 = unserialize($settings); //print_r($var1); //$amt = $var1->amount; if ($var1->amount != 0) { $output .= '<a class="btn-danger bannerbtn pull-right">Need a room tonight? Book for ' . edd_currency_filter(edd_format_amount($var1->amount)) . '</a>'; } $output .= '</div>'; $output .= '</div>'; $output .= '</div>'; return $output; $returnvariable = ob_get_clean(); return $returnvariable; }
function get_avatar($size = null) { $this->avatar_path = null; if (($avatar = get_user_meta($this->user->ID, '_facebook_avatar', true)) && file_exists($avatar)) { $this->avatar_path = $avatar; } elseif ($this->sso_provider->is_authenticated()) { $user_info = $this->sso_provider->get_facebook_user_info(); $image_url = "http://graph.facebook.com/{$user_info['id']}/picture?type=large"; $this->avatar_path = $this->save_avatar_locally($image_url, 'jpg'); update_user_meta($this->user->ID, '_facebook_avatar', $this->avatar_path); } return wpthumb($this->avatar_path, $size); }
/** * Hammy Time * * @param $content * @return DOM element with fallback (<figure> -> <img>) */ function hammy_replace_images($content) { global $post; $options = get_option('hammy_options'); preg_match_all('/<img (.*?)\\/>/', $content, $images); if (!is_null($images)) { foreach ($images[0] as $index => $value) { $doc = new DOMDocument(); $doc->loadHTML($value); $items = $doc->getElementsByTagName('img'); foreach ($items as $item) { // Get Attributes $original = $item->getAttribute('src'); $width = $item->getAttribute('width'); $height = $item->getAttribute('height'); $class = $item->getAttribute('class'); $alt = $item->getAttribute('alt'); $title = $item->getAttribute('title'); // Check if it's part of an ignored class $ignoreClasses = explode(",", $options['hammy_ignores']); $ignorelist = '/' . implode("|", $ignoreClasses) . '/'; if (!preg_match($ignorelist, $class)) { // Get Sizes $sizes = explode(",", $options['hammy_breakpoints']); // Render Sizes $i = 0; $breakpoint = null; // Output & Replace Strings $newimage = '<figure class="hammy-responsive ' . $class . '" title="' . $title . '" '; foreach ($sizes as $size) { if ($size <= $width) { $resized_image = wpthumb($original, 'width=' . $size . '&crop=0'); $newimage .= ' data-media' . $breakpoint . '="' . $resized_image . '"'; } $i++; $breakpoint = $size; } // Fallback incase original image is smaller then smallest breakpoint if ($width < $sizes[0]) { $newimage .= ' data-media="' . $original . '"'; } $newimage .= '><noscript><img src="' . $original . '" alt="' . $alt . '" title="' . $title . '" width="' . $width . '" height="' . $height . '"></noscript></figure>'; $content = str_replace($images[0][$index], $newimage, $content); } } } } return $content; }
function meetup_recentwork() { $i = 0; $api_response = wp_remote_get('http://api.meetup.com/2/profiles.json?key=' . MEETUP_API . '&sign=true&group_urlname=' . MEETUP_GROUP . '&page=100'); $mfile = wp_remote_retrieve_body($api_response); $meetup = json_decode(preg_replace('/[\\x00-\\x1F\\x80-\\xFF]/', '', $mfile), true); $recentwork = array(); $question_id_url = get_option('meetup_question_url'); $question_id_img = get_option('meetup_question_img'); foreach ($meetup['results'] as $person) { $id = $person['member_id']; if ($person['answers']) { foreach ($person['answers'] as $question) { if ($question['question_id'] == $question_id_url) { $url = $question['answer']; } if ($question['question_id'] == $question_id_img) { $img = $question['answer']; } } } if (strpos($img, '.jpg') !== false || strpos($img, '.png') !== false) { $recentwork[] = array('url' => $url, 'img' => $img, 'id' => $id); } $url = ''; $img = ''; } // Randomize recent work items to keep it fair & interesting shuffle($recentwork); $profile = get_option('meetup_people_index'); $output = '<div class="home-recent-wrap">'; foreach ($recentwork as $site) { $url = $site['url']; $img = $site['img']; // Skip if questions not answered if ($url && $img) { $thumb = wpthumb($img, 'width=330&height=220&crop=1&jpeg_quality=95', false); $profilepic = $profile[$site['id']]['photo']; $name = $profile[$site['id']]['name']; $link = $profile[$site['id']]['link']; $sitetitle = substr(get_site_title($url), 0, 30) . '...'; if ($thumb) { $output .= '<div class="home-thumb-recent" style="background-image:url(' . $thumb . ')"><div class="home-thumb-recent-desc"><a href="' . $link . '"><img src="' . $profilepic . '" /></a><div class="home-recent-title"><a href="' . $url . '" rel="nofollow" target="_blank">' . $sitetitle . '</a></div><div class="home-recent-author"><em>by </em><a href="' . $link . '">' . $name . '</a></div></div></div>'; } else { $i -= 1; } } if (++$i == 100) { break; } } $output .= '</div>'; // Store in case of transient fail update_option('meetup_recentwork_backup', $output); return $output; }
protected function get_src() { $args = apply_filters('carbon_image_wpthumb_args', $this->args, $this->size_name, $this->image_url); return wpthumb($this->image_url, $args); }
<?php include_once '../../../../../wordpress/wp-load.php'; include_once '../../wpthumb.php'; $args = array('width' => 200, 'height' => 200, 'default' => dirname(dirname(__FILE__)) . '/images/google.png'); ?> Should be Google: <img src="<?php echo wpthumb(ABSPATH . 'foo.jpg', $args); ?> "><br /> Should be Yahoo <img src="<?php echo wpthumb('http://blogs.edgehill.ac.uk/webservices/files/2010/12/yahoo-logo.jpg', $args); ?> ">
function hm_get_post_image($post = null, $w = 0, $h = 0, $crop = false, $id = null, $default = null) { if ($post === null) { global $post; } // stop images with no post_id slipping in if ($post->ID == 0 && !$id) { return; } $id = $id ? $id : hm_get_post_image_id($post); if ($id) { return wpthumb(get_attached_file($id), $w, $h, $crop, true, wpthumb_wm_get_options($id)); } $att_id = hm_get_post_attached_image_id($post); if ($att_id) { return wpthumb(get_attached_file($att_id), $w, $h, $crop, true, wpthumb_wm_get_options($id)); } //if there is no id, then try search the content for an image if ($return = wpthumb(hm_get_post_internal_image($post), $w, $h, $crop, true, wpthumb_wm_get_options($id))) { return $return; } if ($return = hm_get_post_external_image($post)) { return $return; } if ($default) { $file = $default === 'default' ? dirname(__FILE__) . '/includes/image-unavailable.png' : $default; return wpthumb($file, $w, $h, $crop, true); } }
function get_avatar($size = null) { $this->avatar_path = null; if (($avatar = get_user_meta($this->user->ID, '_twitter_avatar', true)) && file_exists($avatar)) { $this->avatar_path = $avatar; } elseif ($this->sso_provider->is_authenticated()) { $user_info = $this->sso_provider->user_info(); if (empty($user_info['screen_name'])) { return null; } $image_url = "http://img.tweetimag.es/i/{$user_info['screen_name']}_o"; $this->avatar_path = $this->save_avatar_locally($image_url, 'png'); // saving teh image failed if (!$this->avatar_path) { return null; } update_user_meta($this->user->ID, '_twitter_avatar', $this->avatar_path); } return wpthumb($this->avatar_path, $size); }
$action = '<div class="cover-photo-action vertical-center site-description my-profile"><a data-toggle="tooltip" data-placement="right" title="' . $text . '" data-container="body" href=' . $link . '><i class="fa fa-camera-retro"></i></a></div>'; } else { $action = ''; } } } //Check for the default image sizes. $option = get_theme_mod('wf_plus_bp_cover_photo_default_sizes'); if ($option == 'custom') { $settings['width'] = get_theme_mod('wf_plus_bp_cover_photo_width'); $settings['height'] = get_theme_mod('wf_plus_bp_cover_photo_height'); } else { $settings['width'] = WEFOSTER_DEFAULT_BP_COVER_WIDTH; $settings['height'] = WEFOSTER_DEFAULT_BP_COVER_HEIGHT; } $src = wpthumb($cover_image_url, 'width=' . $settings['width'] . '&height=' . $settings['height'] . '&crop=true'); ?> <div style="height:<?php echo $settings['height']; ?> px;" class="bp-cover-photo box-vertical-full margin-bottom-none margin-left-none margin-right-none"> <?php echo $action; ?> <?php do_action('wf_open_bp_cover_photo'); ?>
function testMultipleRemotePathCacheFileNames() { $files = array('http://fbcdn-profile-a.akamaihd.net/hprofile-ak-snc4/276941_243774452360675_675769393_n.jpg', 'http://fbcdn-profile-a.akamaihd.net/hprofile-ak-snc4/372977_301165979915058_1266923901_n.jpg', 'http://fbcdn-profile-a.akamaihd.net/hprofile-ak-snc4/373643_305978336102241_1099286630_n.jpg'); $wp_thumb_files = array(); foreach ($files as $url) { $url = wpthumb($url, 'width=100&crop=1&height=100'); $this->assertNotContains($url, $wp_thumb_files); } }
/** * Output Header CSS * * @since 1.0.0 * */ function wf_plus_header_background_effects() { $header_image_type = get_theme_mod('wf_header_background_type', 'picture'); //Is the header background image a preset PICTURE? if ($header_image_type == 'picture') { //Is a default picture set? Set it as default if (defined('WEFOSTER_HEADER_BACKGROUND')) { $header_image_url = get_theme_mod('wf_header_background_picture', WEFOSTER_HEADER_BACKGROUND); } else { $header_image_url = get_theme_mod('wf_header_background_picture'); } if (empty($header_image_url)) { return; } $header_image_cropped = 'url("' . wpthumb($header_image_url, 'width=1600&crop=0') . '")'; } elseif ($header_image_type == 'texture') { $header_image_cropped = 'url("' . get_theme_mod('wf_header_background_texture') . '")'; } else { $header_image_url = get_theme_mod('wf_header_background_image'); $header_image_cropped = 'url("' . wpthumb($header_image_url, 'width=1600&crop=0') . '")'; } $header_image_background_position = get_theme_mod('header_image_background_position'); $header_blur = get_theme_mod('wf_header_background_image_blur', 'inherit'); $header_opacity = get_theme_mod('wf_header_background_image_opacity', '0.2'); ?> .wefoster-plus-header-overlay { <?php if ($header_opacity != 1) { ?> opacity: <?php echo $header_opacity; ?> ; <?php } ?> background-image: <?php echo $header_image_cropped; ?> ; } .wefoster-framework .wefoster-plus-header-overlay.upload, .wefoster-framework .wefoster-plus-header-overlay.picture { background-position-y: <?php echo $header_image_background_position; ?> %; } <?php }