Пример #1
0
 /**
  * Provide an array of available image sizes and corresponding dimensions.
  * Similar to get_intermediate_image_sizes() except that it includes image sizes' dimensions, not just their names.
  *
  * @global $wp_additional_image_sizes
  * @uses get_option
  * @return array
  */
 protected static function image_sizes()
 {
     if (null == self::$image_sizes) {
         global $_wp_additional_image_sizes;
         // Populate an array matching the data structure of $_wp_additional_image_sizes so we have a consistent structure for image sizes
         $images = array('thumb' => array('width' => intval(get_option('thumbnail_size_w')), 'height' => intval(get_option('thumbnail_size_h')), 'crop' => (bool) get_option('thumbnail_crop')), 'medium' => array('width' => intval(get_option('medium_size_w')), 'height' => intval(get_option('medium_size_h')), 'crop' => false), 'large' => array('width' => intval(get_option('large_size_w')), 'height' => intval(get_option('large_size_h')), 'crop' => false), 'full' => array('width' => null, 'height' => null, 'crop' => false));
         // Compatibility mapping as found in wp-includes/media.php
         $images['thumbnail'] = $images['thumb'];
         // Update class variable, merging in $_wp_additional_image_sizes if any are set
         if (is_array($_wp_additional_image_sizes) && !empty($_wp_additional_image_sizes)) {
             self::$image_sizes = array_merge($images, $_wp_additional_image_sizes);
         } else {
             self::$image_sizes = $images;
         }
     }
     return is_array(self::$image_sizes) ? self::$image_sizes : array();
 }
Пример #2
0
/**
 * Plugin Name: Tachyon
 * Version: 0.9
 * Description: A standalone tachyon proof of concept
 * Author: Joe Hoyle | Human Made | Automattic Inc
 */
/**
 * Copyright: Automattic Inc
 * Copyright: Human Made Limited
 */
if (!defined('TACHYON_URL') || !TACHYON_URL) {
    return;
}
require_once dirname(__FILE__) . '/inc/class-tachyon.php';
Tachyon::instance();
/**
 * Generates a Tachyon URL.
 *
 * @see http://developer.wordpress.com/docs/tachyon/
 *
 * @param string $image_url URL to the publicly accessible image you want to manipulate
 * @param array|string $args An array of arguments, i.e. array( 'w' => '300', 'resize' => array( 123, 456 ) ), or in string form (w=123&h=456)
 * @return string The raw final URL. You should run this through esc_url() before displaying it.
 */
function tachyon_url($image_url, $args = array(), $scheme = null)
{
    $upload_dir = wp_upload_dir();
    $upload_baseurl = $upload_dir['baseurl'];
    if (is_multisite()) {
        $upload_baseurl = preg_replace('#/sites/[\\d]+#', '', $upload_baseurl);