instance() 공개 정적인 메소드

Singleton implementation
public static instance ( ) : object
리턴 object
 public static function execute()
 {
     if (!class_exists('Jetpack', false)) {
         return;
     }
     $jetpack_active_modules = get_option('jetpack_active_modules');
     if ($jetpack_active_modules && in_array('photon', $jetpack_active_modules) && class_exists('Jetpack_Photon', false)) {
         // deactivate photon
         remove_filter('image_downsize', array(Jetpack_Photon::instance(), 'filter_image_downsize'));
     }
 }
예제 #2
0
 function check_image_size($id, $size)
 {
     remove_filter('image_downsize', array(Jetpack_Photon::instance(), 'filter_image_downsize'));
     $imagedata = wp_get_attachment_image_src($id, $size);
     add_filter('image_downsize', array(Jetpack_Photon::instance(), 'filter_image_downsize'), 10, 3);
     if ($imagedata) {
         $size = $this->get_image_sizes($size);
         if ($imagedata[1] == $size['width'] and $imagedata[2] == $size['height']) {
             return $imagedata[0];
         }
     } else {
         return false;
     }
 }
예제 #3
0
 private function get_image_size_links($post)
 {
     /* Set up an empty array for the links. */
     $links = array();
     /* Get the intermediate image sizes and add the full size to the array. */
     $sizes = get_intermediate_image_sizes();
     $sizes[] = 'full';
     /* Loop through each of the image sizes. */
     $i = 0;
     foreach ($sizes as $size) {
         /* Get the image source, width, height, and whether it's intermediate. */
         remove_filter('image_downsize', array(Jetpack_Photon::instance(), 'filter_image_downsize'));
         if ($image = wp_get_attachment_image_src($post->ID, $size)) {
             $links[$i]['url'] = $image[0];
             $links[$i]['type'] = $size;
             $links[$i]['width'] = $image[1];
             $links[$i]['height'] = $image[2];
             $i++;
         }
         add_filter('image_downsize', array(Jetpack_Photon::instance(), 'filter_image_downsize'), 10, 3);
     }
     return $links;
 }
예제 #4
0
파일: photon.php 프로젝트: kanei/vantuch.cz
<?php

/**
 * Module Name: Photon
 * Module Description: Speed up images and photos.
 * Jumpstart Description: Mirrors and serves your images from our free and fast image CDN, improving your site’s performance with no additional load on your servers.
 * Sort Order: 25
 * Recommendation Order: 1
 * First Introduced: 2.0
 * Requires Connection: Yes
 * Auto Activate: No
 * Module Tags: Photos and Videos, Appearance, Recommended
 * Feature: Recommended, Jumpstart, Appearance
 * Additional Search Queries: photon, image, cdn, performance, speed
 */
Jetpack::dns_prefetch(array('//i0.wp.com', '//i1.wp.com', '//i2.wp.com'));
Jetpack_Photon::instance();
예제 #5
0
 /**
  * @author dereksmart
  * @covers Jetpack_Photon::filter_image_downsize
  * @since 3.9.0
  */
 public function test_photon_return_custom_size_array_dimensions_no_meta()
 {
     global $content_width;
     $content_width = 0;
     $test_image = $this->_get_image('large', false);
     // Declaring the size array directly, unknown size of 400 by 400. Scaled, it should be 400 by 300.
     $this->assertEquals('fit=400%2C400', $this->_get_query(Jetpack_Photon::instance()->filter_image_downsize(false, $test_image, array(400, 400))));
     wp_delete_attachment($test_image);
     $this->_remove_image_sizes();
 }
예제 #6
0
function wallpaper_download_links($id)
{
    if (!wp_attachment_is_image(intval($id))) {
        return;
    }
    $wallpaper_afmetingen_links = array();
    $groottes = array();
    //get_intermediate_image_sizes();
    $groottes[] = 'wallpaper-1280x1024';
    $groottes[] = 'wallpaper-1600x1200';
    $groottes[] = 'wallpaper-1920x1080';
    $groottes[] = 'full';
    foreach ($groottes as $grootte) {
        $photon_uitzetten = remove_filter('image_downsize', array(Jetpack_Photon::instance(), 'filter_image_downsize'));
        //$wallpaper = wp_get_attachment_image_src( get_the_ID(), $grootte );
        $wallpaper = wp_get_attachment_image_src(intval($id), $grootte);
        if ($photon_uitzetten) {
            add_filter('image_downsize', array(Jetpack_Photon::instance(), 'filter_image_downsize'), 10, 3);
        }
        //if ( !empty( $wallpaper ) && ( '' == $wallpaper[3] || 'full' == $grootte ) ) {
        if (!empty($wallpaper)) {
            if (intval($wallpaper[1]) > 1024 && (intval($wallpaper[1]) == 1280 || intval($wallpaper[1]) == 1600 || intval($wallpaper[1]) == 1920)) {
                $wallpaper_afmetingen_links[] = '<a class="knop meer" title="Download deze wallpaper in formaat ' . $wallpaper[1] . '&times;' . $wallpaper[2] . ' pixels" target="_blank" href="' . $wallpaper[0] . '">' . $wallpaper[1] . '&times;' . $wallpaper[2] . '</a>';
            }
        }
    }
    return join('', $wallpaper_afmetingen_links);
}
예제 #7
0
 /**
  * @author kraftbj
  * @covers Jetpack_Photon::filter_image_downsize
  * @since 3.9.0
  */
 public function test_photon_return_jetpack_soft_oversized_after_upload()
 {
     global $content_width;
     $content_width = 0;
     $test_image = $this->_get_image();
     // Using a custom size, declared after the file was uploaded
     // (thus unknown per WP, relying solely on Photon), hard crop defined 700 width.
     $this->assertEquals('fit=1600%2C1200', $this->_get_query(Jetpack_Photon::instance()->filter_image_downsize(false, $test_image, 'jetpack_soft_oversized_after_upload')));
     wp_delete_attachment($test_image);
     $this->_remove_image_sizes();
 }
 /**
  * Return image info for the pledge thumbnail.
  * This uses the provided image id, enabling the SharingMetadata class to call it
  * with the id set in its metadata.
  *
  * @param int $screenWidth - pass 0 for default screen width
  * @param int $imageId
  * @return array - URL, width, height
  */
 public static function getPledgeThumbnailById($screenWidth, $imageId)
 {
     $width = self::getPledgeThumbnailWidth($screenWidth);
     // disable photon - we don't want to serve those images from the CDN
     if (class_exists('Jetpack_Photon')) {
         $photon_removed = remove_filter('image_downsize', array(\Jetpack_Photon::instance(), 'filter_image_downsize'));
     }
     // use the "large" image size.  Picking a pre-determined size will allow us to watermark those specific images,
     // even though the selected size may be too large for the device
     $image = image_downsize($imageId, AWC_SOCIAL_PLEDGE_SHARE_IMAGE_SIZE);
     // re-enable photon
     if (!empty($photon_removed)) {
         add_filter('image_downsize', array(\Jetpack_Photon::instance(), 'filter_image_downsize'), 10, 3);
     }
     // scale the image via width / height
     $size = image_constrain_size_for_editor($image[1], $image[2], [$width, $width]);
     return [$image[0], $size[0], $size[1]];
 }
 /**
  * set and retreive variables for the featured image.
  * @return $item
  *
  * @since  1.1.0
  */
 public static function get_image_variables()
 {
     $item = new stdClass();
     // variables internal to this function
     $displaysetting = get_option('displayfeaturedimagegenesis');
     $fallback = $displaysetting['default'];
     // url only
     // sitewide variables used outside this function
     $item->backstretch = '';
     // turn Photon off so we can get the correct image
     $photon_removed = '';
     if (class_exists('Jetpack') && Jetpack::is_module_active('photon')) {
         $photon_removed = remove_filter('image_downsize', array(Jetpack_Photon::instance(), 'filter_image_downsize'));
     }
     /**
      * create a filter for user to optionally force post types to use the large image instead of backstretch
      * @var filter
      *
      * @since  2.0.0
      */
     $use_large_image = apply_filters('display_featured_image_genesis_use_large_image', array());
     $image_size = 'displayfeaturedimage_backstretch';
     if (in_array(get_post_type(), $use_large_image)) {
         $image_size = 'large';
     }
     $image_id = self::set_image_id();
     $item->backstretch = wp_get_attachment_image_src($image_id, $image_size);
     // set a content variable so backstretch doesn't show if full size image exists in post.
     $item->content = '';
     // declare this last so that $item->backstretch is set.
     if (!is_admin() && is_singular()) {
         $fullsize = wp_get_attachment_image_src($image_id, 'full');
         $post = get_post();
         $item->content = strpos($post->post_content, 'src="' . $fullsize[0]);
         if (false !== $item->content) {
             $source_id = '';
             $term_image = display_featured_image_genesis_get_term_image_id();
             $default_image = display_featured_image_genesis_get_default_image_id();
             // reset backstretch image source to term image if it exists and the featured image is being used in content.
             if (!empty($term_image)) {
                 $source_id = $term_image;
             } elseif (!empty($fallback)) {
                 // else, reset backstretch image source to fallback.
                 $source_id = $default_image;
             }
             $item->backstretch = wp_get_attachment_image_src($source_id, $image_size);
             $item->content = strpos($post->post_content, 'src="' . $item->backstretch[0]);
         }
     }
     // turn Photon back on
     if ($photon_removed) {
         add_filter('image_downsize', array(Jetpack_Photon::instance(), 'filter_image_downsize'), 10, 3);
     }
     // $title is set by new title function
     $title = self::set_item_title();
     /**
      * Optional filter to change the title text
      * @since 2.2.0
      */
     $item->title = apply_filters('display_featured_image_genesis_title', $title);
     return $item;
 }
 /**
  * @author scotchfield
  * @covers Jetpack_Photon::instance
  * @since 3.2
  */
 public function test_photon_instance_singleton()
 {
     $photon = Jetpack_Photon::instance();
     $this->assertEquals($photon, Jetpack_Photon::instance());
 }
예제 #11
0
 private static function getImageUrl($imageId, $network)
 {
     // disable photon - we don't want to serve those images from the CDN
     if (class_exists('Jetpack_Photon')) {
         $photon_removed = remove_filter('image_downsize', array(\Jetpack_Photon::instance(), 'filter_image_downsize'));
     }
     // use the "large" image size.  Picking a pre-determined size will allow us to watermark those specific images,
     // even though the selected size may be too large for the device
     $image = image_downsize($imageId, AWC_SOCIAL_PLEDGE_SHARE_IMAGE_SIZE);
     // re-enable photon
     if (!empty($photon_removed)) {
         add_filter('image_downsize', array(\Jetpack_Photon::instance(), 'filter_image_downsize'), 10, 3);
     }
     if ($network) {
         return SocialImages::resizeForNetwork($image[0], $imageId, [$image[1], $image[2]], $network);
     }
     return $image[0];
 }
예제 #12
0
<?php

/**
 * Jetpack compatibility file
 *
 * @since 4.2.0
 */
// File Security Check
if (!defined('ABSPATH')) {
    exit;
}
$jetpack_active_modules = get_option('jetpack_active_modules');
if ($jetpack_active_modules && in_array('photon', $jetpack_active_modules)) {
    // deactivate photon
    remove_filter('image_downsize', array(Jetpack_Photon::instance(), 'filter_image_downsize'));
}