当前位置: 首页>>代码示例>>PHP>>正文


PHP jetpack_photon_url函数代码示例

本文整理汇总了PHP中jetpack_photon_url函数的典型用法代码示例。如果您正苦于以下问题:PHP jetpack_photon_url函数的具体用法?PHP jetpack_photon_url怎么用?PHP jetpack_photon_url使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了jetpack_photon_url函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: format_theme

 /**
  * Format a theme for the public API
  * @param  object $theme WP_Theme object
  * @return array Named array of theme info used by the API
  */
 protected function format_theme($theme)
 {
     $fields = array('name' => 'Name', 'description' => 'Description', 'tags' => 'Tags', 'version' => 'Version');
     $formatted_theme = array('id' => $theme->get_stylesheet(), 'screenshot' => jetpack_photon_url($theme->get_screenshot(), array(), 'network_path'));
     foreach ($fields as $key => $field) {
         $formatted_theme[$key] = $theme->get($field);
     }
     return $formatted_theme;
 }
开发者ID:lokenxo,项目名称:familygenerator,代码行数:14,代码来源:class.json-api-jetpack-endpoints.php

示例2: wpcom_vip_get_resized_remote_image_url

/**
 * Returns the URL to an image resized and cropped to the given dimensions.
 *
 * You can use this image URL directly -- it's cached and such by our servers.
 * Please use this function to generate the URL rather than doing it yourself as
 * this function uses staticize_subdomain() makes it serve off our CDN network.
 *
 * Somewhat contrary to the function's name, it can be used for ANY image URL, hosted by us or not.
 * So even though it says "remote", you can use it for attachments hosted by us, etc.
 *
 * @link http://vip.wordpress.com/documentation/image-resizing-and-cropping/ Image Resizing And Cropping
 * @param string $url The raw URL to the image (URLs that redirect are currently not supported with the exception of http://foobar.wordpress.com/files/ type URLs)
 * @param int $width The desired width of the final image
 * @param int $height The desired height of the final image
 * @param bool $escape Optional. If true (the default), the URL will be run through esc_url(). Set this to false if you need the raw URL.
 * @return string
 */
function wpcom_vip_get_resized_remote_image_url($url, $width, $height, $escape = true)
{
    $width = (int) $width;
    $height = (int) $height;
    // Photon doesn't support redirects, so help it out by doing http://foobar.wordpress.com/files/ to http://foobar.files.wordpress.com/
    if (function_exists('new_file_urls')) {
        $url = new_file_urls($url);
    }
    $thumburl = jetpack_photon_url($url, array('resize' => array($width, $height)));
    return $escape ? esc_url($thumburl) : $thumburl;
}
开发者ID:alessioCattaneo,项目名称:Mini-Maker-Faire-WordPress-Theme,代码行数:28,代码来源:sponsor.php

示例3: legacy_get_fit_remote_image_url

function legacy_get_fit_remote_image_url($url, $width, $height, $escape = true)
{
    if (class_exists('Jetpack') && Jetpack::is_module_active('photon')) {
        $width = (int) $width;
        $height = (int) $height;
        // Photon doesn't support redirects, so help it out by doing http://foobar.wordpress.com/files/ to http://foobar.files.wordpress.com/
        if (function_exists('new_file_urls')) {
            $url = new_file_urls($url);
        }
        $thumburl = jetpack_photon_url($url, array('fit' => array($width, $height)));
        return $escape ? esc_url($thumburl) : $thumburl;
    }
}
开发者ID:hansstam,项目名称:makerfaire,代码行数:13,代码来源:legacy-helper.php

示例4: uber_grid_get_photon_url

function uber_grid_get_photon_url($url, $options)
{
    $photon_options = array();
    if (isset($options['width']) && (int) $options['width'] && isset($options['height']) && (int) $options['height']) {
        $photon_options['resize'] = array($options['width'], $options['height']);
    } else {
        if (isset($options['width']) && (int) $options['width']) {
            $photon_options['w'] = $options['width'];
        }
        if (isset($options['height']) && (int) $options['height']) {
            $photon_options['h'] = $options['height'];
        }
    }
    //$photon_options['zoom'] = $options['pixel_ratio'];
    return jetpack_photon_url($url, $photon_options);
}
开发者ID:jauregui82,项目名称:WpCaro,代码行数:16,代码来源:functions.php

示例5: get_slides

 /**
  * Fetch the slide collection for a given slideset
  *
  * @uses $_POST['slideset'] Identifies presentation based on slideset ID.
  */
 public function get_slides()
 {
     $slideset_id = intval($_POST['slideset']);
     // $response = array(
     //     'success' => true/false,
     //     'data'    => array(
     //         $child_array_1,
     //         $child_array_2
     //         ...
     //     )
     // }
     $response = array();
     if (0 === $slideset_id) {
         $response['success'] = false;
     } else {
         /** @var SEOSlides_Slideset $slideset */
         $slideset = SEOSlides_Module_Provider::get('SEOSlides Core')->get_slideset($slideset_id);
         $child_data = array();
         // Build an array containing each slide in a separate associative array
         /** @var SEOSlides_Slide $slide */
         foreach ($slideset->slides as $slide) {
             $bg_image = $slide->get_bg_image();
             $bg_id = SEOSlides_Util::get_attachment_id_from_url($bg_image);
             if (false !== $bg_id) {
                 $bg_arr = wp_get_attachment_image_src($bg_id, 'seoslides-thumb');
                 $bg_image = $bg_arr[0];
             }
             $data = array('id' => $slide->ID, 'title' => stripslashes($slide->title), 'content' => $slide->content, 'image' => stripslashes($slide->image), 'bg_image' => $bg_image, 'style' => $slide->style, 'position' => $slide->position, 'preview' => $slide->preview, 'fill_color' => $slide->fill_color, 'seo_title' => $slide->seo_title, 'seo_description' => $slide->seo_description, 'seo_keywords' => $slide->seo_keywords, 'presenter_notes' => wp_trim_words($slide->presenter_notes, 50, ' […]'), 'status' => $slide->status);
             if (isset($data['bg_image']) && function_exists('jetpack_photon_url')) {
                 $data['bg_image'] = jetpack_photon_url($data['bg_image'], array(), '//');
             }
             $oembed = SEOSlides_Slide::get_embed_url($slide->oembed);
             $oembed_thumb = SEOSlides_Slide::get_embed_thumbnail($slide->oembed);
             if (!is_wp_error($oembed) && !is_wp_error($oembed_thumb)) {
                 $data['oembed'] = $oembed;
                 $data['oembed_thumb'] = $oembed_thumb;
             }
             // Build out canvas objects
             $data['objects'] = array_map(array($this, 'sanitize_slide_object'), $slide->objects);
             // Add the object
             $child_data[] = $data;
         }
         $response['success'] = true;
         $response['data'] = $child_data;
     }
     wp_send_json($response);
 }
开发者ID:Neminath,项目名称:lastmile,代码行数:52,代码来源:SEOSlides_Ajax.php

示例6: format_theme

 /**
  * Format a theme for the public API
  * @param  object $theme WP_Theme object
  * @return array Named array of theme info used by the API
  */
 protected function format_theme($theme)
 {
     if (!$theme instanceof WP_Theme) {
         $theme = wp_get_theme($theme);
     }
     $fields = array('name' => 'Name', 'theme_uri' => 'ThemeURI', 'description' => 'Description', 'author' => 'Author', 'author_uri' => 'AuthorURI', 'tags' => 'Tags', 'version' => 'Version');
     $id = $theme->get_stylesheet();
     $formatted_theme = array('id' => $id, 'screenshot' => jetpack_photon_url($theme->get_screenshot(), array(), 'network_path'), 'active' => $id === $this->current_theme_id);
     foreach ($fields as $key => $field) {
         $formatted_theme[$key] = $theme->get($field);
     }
     $update_themes = get_site_transient('update_themes');
     $formatted_theme['update'] = isset($update_themes->response[$id]) ? $update_themes->response[$id] : null;
     $autoupdate_themes = Jetpack_Options::get_option('autoupdate_themes', array());
     $autoupdate = in_array($id, $autoupdate_themes);
     $formatted_theme['autoupdate'] = $autoupdate;
     if (isset($this->log[$id])) {
         $formatted_theme['log'] = $this->log[$id];
     }
     return $formatted_theme;
 }
开发者ID:StefanBonilla,项目名称:CoupSoup,代码行数:26,代码来源:class.jetpack-json-api-themes-endpoint.php

示例7: apply_filter_post_gallery


//.........这里部分代码省略.........
         $rel = '';
         $preserve_click = '';
         $remove_link = false;
         $additional_css_classes = '';
         $attachment_id = intval($attachment_id);
         // See if we have a custom url for this attachment image
         $attachment_meta = get_post_meta($attachment_id, '_gallery_link_url', true);
         if ($attachment_meta) {
             $link = $attachment_meta;
             // Apply filters to the custom link (e.g. the case of prefixing internal
             // links with /en/ or /fr/ etc. for languages on the fly)
             $link = apply_filters('wpgcl_filter_raw_gallery_link_url', $link, $attachment_id, $post_id);
         }
         // See if we have a target for this attachment image
         $attachment_meta = get_post_meta($attachment_id, '_gallery_link_target', true);
         if ($attachment_meta) {
             $target = $attachment_meta;
         }
         if (isset($attr['open_all_in_new_window']) && strtolower(trim($attr['open_all_in_new_window'])) === 'true') {
             // Override setting if the gallery shortcode says to open everything in a new window
             // This should accommodate both "3000 images in new window" guy (to some extent) and allow _blank
             // by default lady to reset her gallery to _blank at once
             $target = '_blank';
         }
         if (isset($attr['open_all_in_same_window']) && strtolower(trim($attr['open_all_in_same_window'])) === 'true') {
             // Override setting if the gallery shortcode says to open everything in the same window
             // This should allow _blank by default lady to set her gallery to _self at once
             $target = '_self';
         }
         // See if we have a rel for this link
         if (isset($attr['rel'])) {
             // Add a rel property to this image link with the specified value
             $rel = $attr['rel'];
             // Note: this is escaped before being dropped in
         }
         // See if we have additional css classes for this attachment image
         $attachment_meta = get_post_meta($attachment_id, '_gallery_link_additional_css_classes', true);
         if ($attachment_meta) {
             $additional_css_classes = trim($attachment_meta);
         }
         // See how to handle click events for this attachment image
         $attachment_meta = get_post_meta($attachment_id, '_gallery_link_preserve_click', true);
         if ($attachment_meta) {
             $preserve_click = $attachment_meta;
         }
         if (isset($attr['preserve_click_events']) && strtolower(trim($attr['preserve_click_events'])) === 'true') {
             // Override the individual setting if the gallery shortcode says to preserve on all
             $preserve_click = 'preserve';
         }
         // See if we need to remove the link for this image or not
         if (strtolower(trim($link)) === '[none]' || isset($attr['remove_links']) && strtolower(trim($attr['remove_links'])) === 'true') {
             $remove_link = true;
         }
         if ($link != '' || $target != '' || $rel != '' || $remove_link || $additional_css_classes != '') {
             // Replace the attachment href
             $needle = get_attachment_link($attachment_id);
             $output = self::replace_link($needle, $link, $target, $rel, $preserve_click, $remove_link, $additional_css_classes, $output);
             // Replace the file href
             list($needle) = wp_get_attachment_image_src($attachment_id, '');
             $output = self::replace_link($needle, $link, $target, $rel, $preserve_click, $remove_link, $additional_css_classes, $output);
             // Also, in case of jetpack photon with tiled galleries...
             if (function_exists('jetpack_photon_url')) {
                 // The CDN url currently is generated with "$subdomain = rand( 0, 2 );",
                 // and then "$photon_url  = "http://i{$subdomain}.wp.com/$image_host_path";".
                 // So just to cover our bases, loop over a slightly larger range of numbers
                 // to make sure we include all possibilities for what the photon url
                 // could be.  The max $j value may need to be increased someday if they
                 // get a lot busier. Also the URL could change. I guess I'll cross
                 // those bridges when we come to them. Blah.
                 for ($j = 0; $j < 10; $j++) {
                     $needle_parts = explode('.wp.com', jetpack_photon_url($needle));
                     if (count($needle_parts) == 2) {
                         $needle_part_1 = preg_replace('/\\d+$/U', '', $needle_parts[0]);
                         $needle_part_2 = '.wp.com' . $needle_parts[1];
                         $needle_reassembled = $needle_part_1 . $j . $needle_part_2;
                         $output = self::replace_link($needle_reassembled, $link, $target, $rel, $preserve_click, $remove_link, $additional_css_classes, $output);
                     }
                 }
             }
             // Replace all possible file sizes - some themes etc.
             // may use sizes other than the full version
             $attachment_metadata = wp_get_attachment_metadata($attachment_id);
             if ($attachment_metadata !== false && isset($attachment_metadata['sizes'])) {
                 $attachment_sizes = $attachment_metadata['sizes'];
                 if (is_array($attachment_sizes) && count($attachment_sizes) > 0) {
                     foreach ($attachment_sizes as $attachment_size => $attachment_info) {
                         list($needle) = wp_get_attachment_image_src($attachment_id, $attachment_size);
                         $output = self::replace_link($needle, $link, $target, $rel, $preserve_click, $remove_link, $additional_css_classes, $output);
                     }
                     // End of foreach attachment size
                 }
                 // End if we have attachment sizes
             }
             // End if we have attachment metadata (specifically sizes)
         }
         // End if we have a link to swap in or a target to add
     }
     // End foreach post attachment
     return $output;
 }
开发者ID:jenniferOlsen,项目名称:jennyo-wp,代码行数:101,代码来源:wp-gallery-custom-links.php

示例8: fit_image_url

 /**
  * Takes an image URL and pixel dimensions then returns a URL for the
  * resized and croped image.
  *
  * @param  string $src
  * @param  int    $dimension
  * @return string            Transformed image URL
  */
 static function fit_image_url($src, $width, $height)
 {
     $width = (int) $width;
     $height = (int) $height;
     // Umm...
     if ($width < 1 || $height < 1) {
         return $src;
     }
     // See if we should bypass WordPress.com SaaS resizing
     if (has_filter('jetpack_images_fit_image_url_override')) {
         return apply_filters('jetpack_images_fit_image_url_override', $src, $width, $height);
     }
     // If WPCOM hosted image use native transformations
     $img_host = parse_url($src, PHP_URL_HOST);
     if ('.files.wordpress.com' == substr($img_host, -20)) {
         return add_query_arg(array('w' => $width, 'h' => $height, 'crop' => 1), $src);
     }
     // Use Photon magic
     if (function_exists('jetpack_photon_url')) {
         return jetpack_photon_url($src, array('resize' => "{$width},{$height}"));
     }
     // Arg... no way to resize image using WordPress.com infrastructure!
     return $src;
 }
开发者ID:dtekcth,项目名称:datateknologer.se,代码行数:32,代码来源:class.jetpack-post-images.php

示例9: square_image_url

 /**
  * Takes an image URL and a pixel dimensions and returns a URL for the
  * squared up image if possible.
  *
  * @param  string $src
  * @param  int    $dimension
  * @return string            Transformed image URL
  */
 static function square_image_url($src, $dimension)
 {
     $dimension = (int) $dimension;
     // Umm...
     if ($dimension < 1) {
         return $src;
     }
     // If WPCOM hosted image use native transformations
     $img_host = parse_url($src, PHP_URL_HOST);
     if ('.files.wordpress.com' == substr($img_host, -20)) {
         return add_query_arg(array('w' => $dimension, 'h' => $dimension, 'crop' => 1), $src);
     }
     // Use Photon magic
     if (function_exists('jetpack_photon_url')) {
         return jetpack_photon_url($src, array('resize' => "{$dimension},{$dimension}"));
     }
     // Arg... no way to resize image using WordPress.com infrastructure!
     return $src;
 }
开发者ID:KurtMakesWeb,项目名称:CandG,代码行数:27,代码来源:class.jetpack-post-images.php

示例10: get_thumbnail_url

 /**
  * Returns the attributes for a given attachment thumbnail. Meant for hooking into image_downsize().
  *
  * @param $existing_resize array|false Any existing data. Returned on no action.
  * @param $attachment_id int Attachment ID.
  * @param $size string Thumbnail size name.
  * @return mixed Array of thumbnail details (URL, width, height, is_intermedite) or the previous data.
  */
 public function get_thumbnail_url($existing_resize, $attachment_id, $size)
 {
     // Named sizes only
     if (is_array($size)) {
         return $existing_resize;
     }
     $coordinates = $this->get_coordinates($attachment_id, $size);
     if (!$coordinates || !is_array($coordinates) || 4 != count($coordinates)) {
         return $existing_resize;
     }
     if (!($thumbnail_size = $this->get_thumbnail_dimensions($size))) {
         return $existing_resize;
     }
     list($selection_x1, $selection_y1, $selection_x2, $selection_y2) = $coordinates;
     if (function_exists('jetpack_photon_url')) {
         $url = jetpack_photon_url(wp_get_attachment_url($attachment_id), array('crop' => array($selection_x1 . 'px', $selection_y1 . 'px', $selection_x2 - $selection_x1 . 'px', $selection_y2 - $selection_y1 . 'px'), 'resize' => array($thumbnail_size['width'], $thumbnail_size['height'])));
     } else {
         $url = wp_get_attachment_url($attachment_id);
     }
     return array($url, $thumbnail_size['width'], $thumbnail_size['height'], true);
 }
开发者ID:gopinathshiva,项目名称:wordpress-vip-plugins,代码行数:29,代码来源:wpcom-thumbnail-editor.php

示例11: widget

 /**
  * Set up the widget display on the front end.
  *
  * @param array $args
  * @param array $instance
  */
 public function widget($args, $instance)
 {
     /** This action is documented in modules/widgets/gravatar-profile.php */
     do_action('jetpack_stats_extra', 'widget_view', 'display_posts');
     /** This filter is documented in core/src/wp-includes/default-widgets.php */
     $title = apply_filters('widget_title', $instance['title']);
     // Enqueue front end assets.
     $this->enqueue_scripts();
     echo $args['before_widget'];
     $data = $this->get_blog_data($instance['url']);
     // check for errors
     if (is_wp_error($data) || empty($data['site_info']['data'])) {
         echo '<p>' . __('Cannot load blog information at this time.', 'jetpack') . '</p>';
         echo $args['after_widget'];
         return;
     }
     $site_info = $data['site_info']['data'];
     if (!empty($title)) {
         echo $args['before_title'] . esc_html($title . ': ' . $site_info->name) . $args['after_title'];
     } else {
         echo $args['before_title'] . esc_html($site_info->name) . $args['after_title'];
     }
     echo '<div class="jetpack-display-remote-posts">';
     if (is_wp_error($data['posts']['data']) || empty($data['posts']['data'])) {
         echo '<p>' . __('Cannot load blog posts at this time.', 'jetpack') . '</p>';
         echo '</div><!-- .jetpack-display-remote-posts -->';
         echo $args['after_widget'];
         return;
     }
     $posts_list = $data['posts']['data'];
     /**
      * Show only as much posts as we need. If we have less than configured amount,
      * we must show only that much posts.
      */
     $number_of_posts = min($instance['number_of_posts'], count($posts_list));
     for ($i = 0; $i < $number_of_posts; $i++) {
         $single_post = $posts_list[$i];
         $post_title = $single_post['title'] ? $single_post['title'] : '( No Title )';
         $target = '';
         if (isset($instance['open_in_new_window']) && $instance['open_in_new_window'] == true) {
             $target = ' target="_blank"';
         }
         echo '<h4><a href="' . esc_url($single_post['url']) . '"' . $target . '>' . esc_html($post_title) . '</a></h4>' . "\n";
         if ($instance['featured_image'] == true && !empty($single_post['featured_image'])) {
             $featured_image = $single_post['featured_image'];
             /**
              * Allows setting up custom Photon parameters to manipulate the image output in the Display Posts widget.
              *
              * @see    https://developer.wordpress.com/docs/photon/
              *
              * @module widgets
              *
              * @since  3.6.0
              *
              * @param array $args Array of Photon Parameters.
              */
             $image_params = apply_filters('jetpack_display_posts_widget_image_params', array());
             echo '<a title="' . esc_attr($post_title) . '" href="' . esc_url($single_post['url']) . '"' . $target . '><img src="' . jetpack_photon_url($featured_image, $image_params) . '" alt="' . esc_attr($post_title) . '"/></a>';
         }
         if ($instance['show_excerpts'] == true) {
             echo $single_post['excerpt'];
         }
     }
     echo '</div><!-- .jetpack-display-remote-posts -->';
     echo $args['after_widget'];
 }
开发者ID:automattic,项目名称:jetpack,代码行数:72,代码来源:wordpress-post-widget.php

示例12: rectangular_talavera

 public function rectangular_talavera($attachments)
 {
     $grouper = new Jetpack_Tiled_Gallery_Grouper($attachments);
     Jetpack_Tiled_Gallery_Shape::reset_last_shape();
     $output = $this->generate_carousel_container();
     foreach ($grouper->grouped_images as $row) {
         $output .= '<div class="gallery-row" style="' . esc_attr('width: ' . $row->width . 'px; height: ' . ($row->height - 4) . 'px;') . '">';
         foreach ($row->groups as $group) {
             $count = count($group->images);
             $output .= '<div class="gallery-group images-' . esc_attr($count) . '" style="' . esc_attr('width: ' . $group->width . 'px; height: ' . $group->height . 'px;') . '">';
             foreach ($group->images as $image) {
                 $size = 'large';
                 if ($image->width < 250) {
                     $size = 'small';
                 }
                 $image_title = $image->post_title;
                 $orig_file = wp_get_attachment_url($image->ID);
                 $link = $this->get_attachment_link($image->ID, $orig_file);
                 $img_src = add_query_arg(array('w' => $image->width, 'h' => $image->height), $orig_file);
                 $output .= '<div class="tiled-gallery-item tiled-gallery-item-' . esc_attr($size) . '"><a href="' . esc_url($link) . '"><img ' . $this->generate_carousel_image_args($image) . ' src="' . esc_url($img_src) . '" width="' . esc_attr($image->width) . '" height="' . esc_attr($image->height) . '" align="left" title="' . esc_attr($image_title) . '" /></a>';
                 if ($this->atts['grayscale'] == true) {
                     $img_src_grayscale = jetpack_photon_url($img_src, array('filter' => 'grayscale'));
                     $output .= '<a href="' . esc_url($link) . '"><img ' . $this->generate_carousel_image_args($image) . ' class="grayscale" src="' . esc_url($img_src_grayscale) . '" width="' . esc_attr($image->width) . '" height="' . esc_attr($image->height) . '" align="left" title="' . esc_attr($image_title) . '" /></a>';
                 }
                 if (trim($image->post_excerpt)) {
                     $output .= '<div class="tiled-gallery-caption">' . wptexturize($image->post_excerpt) . '</div>';
                 }
                 $output .= '</div>';
             }
             $output .= '</div>';
         }
         $output .= '</div>';
     }
     $output .= '</div>';
     return $output;
 }
开发者ID:ugurozer,项目名称:little,代码行数:36,代码来源:tiled-gallery.php

示例13: filter_open_graph_tags

 /**
  * Pass og:image URLs through Photon
  *
  * @param array $tags
  * @param array $parameters
  * @uses jetpack_photon_url
  * @return array
  */
 function filter_open_graph_tags($tags, $parameters)
 {
     if (empty($tags['og:image'])) {
         return $tags;
     }
     $photon_args = array('fit' => sprintf('%d,%d', 2 * $parameters['image_width'], 2 * $parameters['image_height']));
     if (is_array($tags['og:image'])) {
         $images = array();
         foreach ($tags['og:image'] as $image) {
             $images[] = jetpack_photon_url($image, $photon_args);
         }
         $tags['og:image'] = $images;
     } else {
         $tags['og:image'] = jetpack_photon_url($tags['og:image'], $photon_args);
     }
     return $tags;
 }
开发者ID:rbryerking,项目名称:skillcrush-wordpress,代码行数:25,代码来源:class.photon.php

示例14: jetpack_photon_url

<?php

// Check if the author of this post is connected to the Twitter importer,
// if so load their Twitter avatar, if not use their Gravatar
$icon_size = 35;
// In px, how big (square) should the avatar/icon be?
// I'm being a horrible person and accessing options directly to avoid re-loading all the importer code
if (class_exists('Keyring')) {
    if ($importer = get_option('keyring_twitter_importer')) {
        if ($token = $importer['token']) {
            $token = Keyring::get_token_store()->get_token(array('id' => $token, 'type' => 'access'));
            $url = $token->get_meta('picture');
            if ($url) {
                // Use Photon (if available) to resize their icon properly
                if (function_exists('jetpack_photon_url')) {
                    $url = jetpack_photon_url($url, array('resize' => "{$icon_size},{$icon_size}", 'filter' => 'grayscale'));
                }
                // Output that sucka
                echo '<a href="' . get_author_posts_url(false, get_the_author_meta('ID')) . '">';
                echo '<img src="' . esc_url($url) . '" class="format-icon" width="' . esc_attr($icon_size) . '" height="' . esc_attr($icon_size) . '" alt="" />';
                echo '</a>';
                return;
                // Avoid doing the Gravatar, below
            }
        }
    }
}
// No Twitter connection, try to use their Gravatar instead
$gravatar = get_avatar(get_the_author_meta('ID'), $icon_size);
$gravatar = str_replace("class='", "class='format-icon ", $gravatar);
echo '<a href="' . get_author_posts_url(false, get_the_author_meta('ID')) . '">';
开发者ID:Japh,项目名称:Homeroom,代码行数:31,代码来源:once-aside.php

示例15: wpcom_vip_get_resized_attachment_url

/**
 * Returns a URL for a given attachment with the appropriate resizing querystring.
 *
 * Typically, you should be using image sizes for handling this.
 *
 * However, this function can come in handy if you want a specific artibitrary or varying image size.
 *
 * @link http://vip.wordpress.com/documentation/image-resizing-and-cropping/
 *
 * @param int $attachment_id ID of the attachment
 * @param int $width Width of our resized image
 * @param int $height Height of our resized image
 * @param bool $crop (optional) whether or not to crop the image
 * @return string URL of the resized attachmen
 */
function wpcom_vip_get_resized_attachment_url($attachment_id, $width, $height, $crop = false)
{
    $url = wp_get_attachment_url($attachment_id);
    if (!$url) {
        return false;
    }
    $args = array('w' => intval($width), 'h' => intval($height));
    // @todo crop handling?
    return jetpack_photon_url($url, $args, '//');
}
开发者ID:BurlesonBrad,项目名称:vip-mu-plugins-public,代码行数:25,代码来源:vip-utils.php


注:本文中的jetpack_photon_url函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。