コード例 #1
0
 /**
  * Retrieve the t.co URL for an image stored in WP.
  * If necessary, this will post the image to Twitter and extract the URL from the resulting status.
  *
  * @param $imageId
  * @return mixed|string
  */
 public function getTwitterUrl($imageId, $imageUrl)
 {
     $url = get_post_meta($imageId, 'twitter_url', true);
     // wonder if we should test it to make sure it is still OK?
     if (!$url) {
         $path = SocialImages::getImagePath($imageUrl);
         $url = $this->uploadPicture($imageId, $path);
         update_post_meta($imageId, 'twitter_url', $url);
     }
     return $url;
 }
コード例 #2
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];
 }