class.jetpack-post-images.php 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656
  1. <?php
  2. /**
  3. * Useful for finding an image to display alongside/in representation of a specific post.
  4. *
  5. * Includes a few different methods, all of which return a similar-format array containing
  6. * details of any images found. Everything can (should) be called statically, it's just a
  7. * function-bucket. You can also call Jetpack_PostImages::get_image() to cycle through all of the methods until
  8. * one of them finds something useful.
  9. *
  10. * This file is included verbatim in Jetpack
  11. */
  12. class Jetpack_PostImages {
  13. /**
  14. * If a slideshow is embedded within a post, then parse out the images involved and return them
  15. */
  16. static function from_slideshow( $post_id, $width = 200, $height = 200 ) {
  17. $images = array();
  18. $post = get_post( $post_id );
  19. if ( ! $post ) {
  20. return $images;
  21. }
  22. if ( ! empty( $post->post_password ) ) {
  23. return $images;
  24. }
  25. if ( false === has_shortcode( $post->post_content, 'slideshow' ) ) {
  26. return $images; // no slideshow - bail
  27. }
  28. $permalink = get_permalink( $post->ID );
  29. // Mechanic: Somebody set us up the bomb
  30. $old_post = $GLOBALS['post'];
  31. $GLOBALS['post'] = $post;
  32. $old_shortcodes = $GLOBALS['shortcode_tags'];
  33. $GLOBALS['shortcode_tags'] = array( 'slideshow' => $old_shortcodes['slideshow'] );
  34. // Find all the slideshows
  35. preg_match_all( '/' . get_shortcode_regex() . '/sx', $post->post_content, $slideshow_matches, PREG_SET_ORDER );
  36. ob_start(); // The slideshow shortcode handler calls wp_print_scripts and wp_print_styles... not too happy about that
  37. foreach ( $slideshow_matches as $slideshow_match ) {
  38. $slideshow = do_shortcode_tag( $slideshow_match );
  39. if ( false === $pos = stripos( $slideshow, 'jetpack-slideshow' ) ) // must be something wrong - or we changed the output format in which case none of the following will work
  40. continue;
  41. $start = strpos( $slideshow, '[', $pos );
  42. $end = strpos( $slideshow, ']', $start );
  43. $post_images = json_decode( wp_specialchars_decode( str_replace( "'", '"', substr( $slideshow, $start, $end - $start + 1 ) ), ENT_QUOTES ) ); // parse via JSON
  44. // If the JSON didn't decode don't try and act on it.
  45. if ( is_array( $post_images ) ) {
  46. foreach ( $post_images as $post_image ) {
  47. if ( !$post_image_id = absint( $post_image->id ) )
  48. continue;
  49. $meta = wp_get_attachment_metadata( $post_image_id );
  50. // Must be larger than 200x200 (or user-specified)
  51. if ( !isset( $meta['width'] ) || $meta['width'] < $width )
  52. continue;
  53. if ( !isset( $meta['height'] ) || $meta['height'] < $height )
  54. continue;
  55. $url = wp_get_attachment_url( $post_image_id );
  56. $images[] = array(
  57. 'type' => 'image',
  58. 'from' => 'slideshow',
  59. 'src' => $url,
  60. 'src_width' => $meta['width'],
  61. 'src_height' => $meta['height'],
  62. 'href' => $permalink,
  63. );
  64. }
  65. }
  66. }
  67. ob_end_clean();
  68. // Operator: Main screen turn on
  69. $GLOBALS['shortcode_tags'] = $old_shortcodes;
  70. $GLOBALS['post'] = $old_post;
  71. return $images;
  72. }
  73. /**
  74. * If a gallery is detected, then get all the images from it.
  75. */
  76. static function from_gallery( $post_id ) {
  77. $images = array();
  78. $post = get_post( $post_id );
  79. if ( ! $post ) {
  80. return $images;
  81. }
  82. if ( ! empty( $post->post_password ) ) {
  83. return $images;
  84. }
  85. $permalink = get_permalink( $post->ID );
  86. /**
  87. * Juggle global post object because the gallery shortcode uses the
  88. * global object.
  89. *
  90. * See core ticket:
  91. * https://core.trac.wordpress.org/ticket/39304
  92. */
  93. if ( isset( $GLOBALS['post'] ) ) {
  94. $juggle_post = $GLOBALS['post'];
  95. $GLOBALS['post'] = $post;
  96. $galleries = get_post_galleries( $post->ID, false );
  97. $GLOBALS['post'] = $juggle_post;
  98. } else {
  99. $GLOBALS['post'] = $post;
  100. $galleries = get_post_galleries( $post->ID, false );
  101. unset( $GLOBALS['post'] );
  102. }
  103. foreach ( $galleries as $gallery ) {
  104. if ( isset( $gallery['type'] ) && 'slideshow' === $gallery['type'] && ! empty( $gallery['ids'] ) ) {
  105. $image_ids = explode( ',', $gallery['ids'] );
  106. $image_size = isset( $gallery['size'] ) ? $gallery['size'] : 'thumbnail';
  107. foreach ( $image_ids as $image_id ) {
  108. $image = wp_get_attachment_image_src( $image_id, $image_size );
  109. if ( ! empty( $image[0] ) ) {
  110. list( $raw_src ) = explode( '?', $image[0] ); // pull off any Query string (?w=250)
  111. $raw_src = wp_specialchars_decode( $raw_src ); // rawify it
  112. $raw_src = esc_url_raw( $raw_src ); // clean it
  113. $images[] = array(
  114. 'type' => 'image',
  115. 'from' => 'gallery',
  116. 'src' => $raw_src,
  117. 'href' => $permalink,
  118. );
  119. }
  120. }
  121. } elseif ( ! empty( $gallery['src'] ) ) {
  122. foreach ( $gallery['src'] as $src ) {
  123. list( $raw_src ) = explode( '?', $src ); // pull off any Query string (?w=250)
  124. $raw_src = wp_specialchars_decode( $raw_src ); // rawify it
  125. $raw_src = esc_url_raw( $raw_src ); // clean it
  126. $images[] = array(
  127. 'type' => 'image',
  128. 'from' => 'gallery',
  129. 'src' => $raw_src,
  130. 'href' => $permalink,
  131. );
  132. }
  133. }
  134. }
  135. return $images;
  136. }
  137. /**
  138. * Get attachment images for a specified post and return them. Also make sure
  139. * their dimensions are at or above a required minimum.
  140. */
  141. static function from_attachment( $post_id, $width = 200, $height = 200 ) {
  142. $images = array();
  143. $post = get_post( $post_id );
  144. if ( ! empty( $post->post_password ) ) {
  145. return $images;
  146. }
  147. $post_images = get_posts( array(
  148. 'post_parent' => $post_id, // Must be children of post
  149. 'numberposts' => 5, // No more than 5
  150. 'post_type' => 'attachment', // Must be attachments
  151. 'post_mime_type' => 'image', // Must be images
  152. 'suppress_filters' => false,
  153. ) );
  154. if ( ! $post_images ) {
  155. return $images;
  156. }
  157. $permalink = get_permalink( $post_id );
  158. foreach ( $post_images as $post_image ) {
  159. $meta = wp_get_attachment_metadata( $post_image->ID );
  160. // Must be larger than 200x200
  161. if ( !isset( $meta['width'] ) || $meta['width'] < $width )
  162. continue;
  163. if ( !isset( $meta['height'] ) || $meta['height'] < $height )
  164. continue;
  165. $url = wp_get_attachment_url( $post_image->ID );
  166. $images[] = array(
  167. 'type' => 'image',
  168. 'from' => 'attachment',
  169. 'src' => $url,
  170. 'src_width' => $meta['width'],
  171. 'src_height' => $meta['height'],
  172. 'href' => $permalink,
  173. );
  174. }
  175. /*
  176. * We only want to pass back attached images that were actually inserted.
  177. * We can load up all the images found in the HTML source and then
  178. * compare URLs to see if an image is attached AND inserted.
  179. */
  180. $html_images = self::from_html( $post_id );
  181. $inserted_images = array();
  182. foreach( $html_images as $html_image ) {
  183. $src = parse_url( $html_image['src'] );
  184. // strip off any query strings from src
  185. if( ! empty( $src['scheme'] ) && ! empty( $src['host'] ) ) {
  186. $inserted_images[] = $src['scheme'] . '://' . $src['host'] . $src['path'];
  187. } elseif( ! empty( $src['host'] ) ) {
  188. $inserted_images[] = set_url_scheme( 'http://' . $src['host'] . $src['path'] );
  189. } else {
  190. $inserted_images[] = site_url( '/' ) . $src['path'];
  191. }
  192. }
  193. foreach( $images as $i => $image ) {
  194. if ( !in_array( $image['src'], $inserted_images ) )
  195. unset( $images[$i] );
  196. }
  197. return $images;
  198. }
  199. /**
  200. * Check if a Featured Image is set for this post, and return it in a similar
  201. * format to the other images?_from_*() methods.
  202. * @param int $post_id The post ID to check
  203. * @return Array containing details of the Featured Image, or empty array if none.
  204. */
  205. static function from_thumbnail( $post_id, $width = 200, $height = 200 ) {
  206. $images = array();
  207. $post = get_post( $post_id );
  208. if ( ! empty( $post->post_password ) ) {
  209. return $images;
  210. }
  211. if ( ! function_exists( 'get_post_thumbnail_id' ) ) {
  212. return $images;
  213. }
  214. $thumb = get_post_thumbnail_id( $post_id );
  215. if ( $thumb ) {
  216. $meta = wp_get_attachment_metadata( $thumb );
  217. // Must be larger than requested minimums
  218. if ( !isset( $meta['width'] ) || $meta['width'] < $width )
  219. return $images;
  220. if ( !isset( $meta['height'] ) || $meta['height'] < $height )
  221. return $images;
  222. $too_big = ( ( ! empty( $meta['width'] ) && $meta['width'] > 1200 ) || ( ! empty( $meta['height'] ) && $meta['height'] > 1200 ) );
  223. if (
  224. $too_big &&
  225. (
  226. ( method_exists( 'Jetpack', 'is_module_active' ) && Jetpack::is_module_active( 'photon' ) ) ||
  227. ( defined( 'IS_WPCOM' ) && IS_WPCOM )
  228. )
  229. ) {
  230. $img_src = wp_get_attachment_image_src( $thumb, array( 1200, 1200 ) );
  231. } else {
  232. $img_src = wp_get_attachment_image_src( $thumb, 'full' );
  233. }
  234. if ( ! is_array( $img_src ) ) {
  235. // If wp_get_attachment_image_src returns false but we know that there should be an image that could be used.
  236. // we try a bit harder and user the data that we have.
  237. $thumb_post_data = get_post( $thumb );
  238. $img_src = array( $thumb_post_data->guid, $meta['width'], $meta['height'] );
  239. }
  240. $url = $img_src[0];
  241. $images = array( array( // Other methods below all return an array of arrays
  242. 'type' => 'image',
  243. 'from' => 'thumbnail',
  244. 'src' => $url,
  245. 'src_width' => $img_src[1],
  246. 'src_height' => $img_src[2],
  247. 'href' => get_permalink( $thumb ),
  248. ) );
  249. }
  250. if ( empty( $images ) && ( defined( 'IS_WPCOM' ) && IS_WPCOM ) ) {
  251. $meta_thumbnail = get_post_meta( $post_id, '_jetpack_post_thumbnail', true );
  252. if ( ! empty( $meta_thumbnail ) ) {
  253. if ( ! isset( $meta_thumbnail['width'] ) || $meta_thumbnail['width'] < $width ) {
  254. return $images;
  255. }
  256. if ( ! isset( $meta_thumbnail['height'] ) || $meta_thumbnail['height'] < $height ) {
  257. return $images;
  258. }
  259. $images = array( array( // Other methods below all return an array of arrays
  260. 'type' => 'image',
  261. 'from' => 'thumbnail',
  262. 'src' => $meta_thumbnail['URL'],
  263. 'src_width' => $meta_thumbnail['width'],
  264. 'src_height' => $meta_thumbnail['height'],
  265. 'href' => $meta_thumbnail['URL'],
  266. ) );
  267. }
  268. }
  269. return $images;
  270. }
  271. /**
  272. * Very raw -- just parse the HTML and pull out any/all img tags and return their src
  273. *
  274. * @param mixed $html_or_id The HTML string to parse for images, or a post id.
  275. * @param int $width Minimum Image width.
  276. * @param int $height Minimum Image height.
  277. *
  278. * @uses DOMDocument
  279. *
  280. * @return Array containing images
  281. */
  282. static function from_html( $html_or_id, $width = 200, $height = 200 ) {
  283. $images = array();
  284. if ( is_numeric( $html_or_id ) ) {
  285. $post = get_post( $html_or_id );
  286. if ( empty( $post ) || ! empty( $post->post_password ) ) {
  287. return $images;
  288. }
  289. $html = $post->post_content; // DO NOT apply the_content filters here, it will cause loops.
  290. } else {
  291. $html = $html_or_id;
  292. }
  293. if ( ! $html ) {
  294. return $images;
  295. }
  296. // Do not go any further if DOMDocument is disabled on the server.
  297. if ( ! class_exists( 'DOMDocument' ) ) {
  298. return $images;
  299. }
  300. // Let's grab all image tags from the HTML.
  301. $dom_doc = new DOMDocument;
  302. // The @ is not enough to suppress errors when dealing with libxml,
  303. // we have to tell it directly how we want to handle errors.
  304. libxml_use_internal_errors( true );
  305. @$dom_doc->loadHTML( $html );
  306. libxml_use_internal_errors( false );
  307. $image_tags = $dom_doc->getElementsByTagName( 'img' );
  308. // For each image Tag, make sure it can be added to the $images array, and add it.
  309. foreach ( $image_tags as $image_tag ) {
  310. $img_src = $image_tag->getAttribute( 'src' );
  311. if ( empty( $img_src ) ) {
  312. continue;
  313. }
  314. // Do not grab smiley images that were automatically created by WP when entering text smilies.
  315. if ( stripos( $img_src, '/smilies/' ) ) {
  316. continue;
  317. }
  318. $meta = array(
  319. 'width' => (int) $image_tag->getAttribute( 'width' ),
  320. 'height' => (int) $image_tag->getAttribute( 'height' ),
  321. );
  322. /**
  323. * Filters the switch to ignore minimum image size requirements. Can be used
  324. * to add custom logic to image dimensions, like only enforcing one of the dimensions,
  325. * or disabling it entirely.
  326. *
  327. * @since 6.4.0
  328. *
  329. * @param bool $ignore Should the image dimensions be ignored?
  330. * @param array $meta Array containing image dimensions parsed from the markup.
  331. */
  332. $ignore_dimensions = apply_filters( 'jetpack_postimages_ignore_minimum_dimensions', false, $meta );
  333. // Must be larger than 200x200 (or user-specified).
  334. if (
  335. ! $ignore_dimensions
  336. && (
  337. empty( $meta['width'] )
  338. || empty( $meta['height'] )
  339. || $meta['width'] < $width
  340. || $meta['height'] < $height
  341. )
  342. ) {
  343. continue;
  344. }
  345. $images[] = array(
  346. 'type' => 'image',
  347. 'from' => 'html',
  348. 'src' => $img_src,
  349. 'src_width' => $meta['width'],
  350. 'src_height' => $meta['height'],
  351. 'href' => '', // No link to apply to these. Might potentially parse for that as well, but not for now.
  352. );
  353. }
  354. return $images;
  355. }
  356. /**
  357. * @param int $post_id The post ID to check
  358. * @param int $size
  359. * @return Array containing details of the image, or empty array if none.
  360. */
  361. static function from_blavatar( $post_id, $size = 96 ) {
  362. $permalink = get_permalink( $post_id );
  363. if ( function_exists( 'blavatar_domain' ) && function_exists( 'blavatar_exists' ) && function_exists( 'blavatar_url' ) ) {
  364. $domain = blavatar_domain( $permalink );
  365. if ( ! blavatar_exists( $domain ) ) {
  366. return array();
  367. }
  368. $url = blavatar_url( $domain, 'img', $size );
  369. } elseif ( function_exists( 'has_site_icon' ) && has_site_icon() ) {
  370. $url = get_site_icon_url( $size );
  371. } else {
  372. return array();
  373. }
  374. return array( array(
  375. 'type' => 'image',
  376. 'from' => 'blavatar',
  377. 'src' => $url,
  378. 'src_width' => $size,
  379. 'src_height' => $size,
  380. 'href' => $permalink,
  381. ) );
  382. }
  383. /**
  384. * Gets a post image from the author avatar.
  385. *
  386. * @param int $post_id The post ID to check.
  387. * @param int $size The size of the avatar to get.
  388. * @param string $default The default image to use.
  389. * @return Array containing details of the image, or empty array if none.
  390. */
  391. static function from_gravatar( $post_id, $size = 96, $default = false ) {
  392. $post = get_post( $post_id );
  393. $permalink = get_permalink( $post_id );
  394. if ( function_exists( 'wpcom_get_avatar_url' ) ) {
  395. $url = wpcom_get_avatar_url( $post->post_author, $size, $default, true );
  396. if ( $url && is_array( $url ) ) {
  397. $url = $url[0];
  398. }
  399. } else {
  400. $url = get_avatar_url( $post->post_author, array(
  401. 'size' => $size,
  402. 'default' => $default,
  403. ) );
  404. }
  405. return array(
  406. array(
  407. 'type' => 'image',
  408. 'from' => 'gravatar',
  409. 'src' => $url,
  410. 'src_width' => $size,
  411. 'src_height' => $size,
  412. 'href' => $permalink,
  413. ),
  414. );
  415. }
  416. /**
  417. * Run through the different methods that we have available to try to find a single good
  418. * display image for this post.
  419. * @param int $post_id
  420. * @param array $args Other arguments (currently width and height required for images where possible to determine)
  421. * @return Array containing details of the best image to be used
  422. */
  423. static function get_image( $post_id, $args = array() ) {
  424. $image = '';
  425. /**
  426. * Fires before we find a single good image for a specific post.
  427. *
  428. * @since 2.2.0
  429. *
  430. * @param int $post_id Post ID.
  431. */
  432. do_action( 'jetpack_postimages_pre_get_image', $post_id );
  433. $media = self::get_images( $post_id, $args );
  434. if ( is_array( $media ) ) {
  435. foreach ( $media as $item ) {
  436. if ( 'image' == $item['type'] ) {
  437. $image = $item;
  438. break;
  439. }
  440. }
  441. }
  442. /**
  443. * Fires after we find a single good image for a specific post.
  444. *
  445. * @since 2.2.0
  446. *
  447. * @param int $post_id Post ID.
  448. */
  449. do_action( 'jetpack_postimages_post_get_image', $post_id );
  450. return $image;
  451. }
  452. /**
  453. * Get an array containing a collection of possible images for this post, stopping once we hit a method
  454. * that returns something useful.
  455. * @param int $post_id
  456. * @param array $args Optional args, see defaults list for details
  457. * @return Array containing images that would be good for representing this post
  458. */
  459. static function get_images( $post_id, $args = array() ) {
  460. // Figure out which image to attach to this post.
  461. $media = false;
  462. /**
  463. * Filters the array of images that would be good for a specific post.
  464. * This filter is applied before options ($args) filter the original array.
  465. *
  466. * @since 2.0.0
  467. *
  468. * @param array $media Array of images that would be good for a specific post.
  469. * @param int $post_id Post ID.
  470. * @param array $args Array of options to get images.
  471. */
  472. $media = apply_filters( 'jetpack_images_pre_get_images', $media, $post_id, $args );
  473. if ( $media )
  474. return $media;
  475. $defaults = array(
  476. 'width' => 200, // Required minimum width (if possible to determine)
  477. 'height' => 200, // Required minimum height (if possible to determine)
  478. 'fallback_to_avatars' => false, // Optionally include Blavatar and Gravatar (in that order) in the image stack
  479. 'avatar_size' => 96, // Used for both Grav and Blav
  480. 'gravatar_default' => false, // Default image to use if we end up with no Gravatar
  481. 'from_thumbnail' => true, // Use these flags to specify which methods to use to find an image
  482. 'from_slideshow' => true,
  483. 'from_gallery' => true,
  484. 'from_attachment' => true,
  485. 'from_html' => true,
  486. 'html_content' => '' // HTML string to pass to from_html()
  487. );
  488. $args = wp_parse_args( $args, $defaults );
  489. $media = false;
  490. if ( $args['from_thumbnail'] )
  491. $media = self::from_thumbnail( $post_id, $args['width'], $args['height'] );
  492. if ( !$media && $args['from_slideshow'] )
  493. $media = self::from_slideshow( $post_id, $args['width'], $args['height'] );
  494. if ( !$media && $args['from_gallery'] )
  495. $media = self::from_gallery( $post_id );
  496. if ( !$media && $args['from_attachment'] )
  497. $media = self::from_attachment( $post_id, $args['width'], $args['height'] );
  498. if ( !$media && $args['from_html'] ) {
  499. if ( empty( $args['html_content'] ) )
  500. $media = self::from_html( $post_id, $args['width'], $args['height'] ); // Use the post_id, which will load the content
  501. else
  502. $media = self::from_html( $args['html_content'], $args['width'], $args['height'] ); // If html_content is provided, use that
  503. }
  504. if ( !$media && $args['fallback_to_avatars'] ) {
  505. $media = self::from_blavatar( $post_id, $args['avatar_size'] );
  506. if ( !$media )
  507. $media = self::from_gravatar( $post_id, $args['avatar_size'], $args['gravatar_default'] );
  508. }
  509. /**
  510. * Filters the array of images that would be good for a specific post.
  511. * This filter is applied after options ($args) filter the original array.
  512. *
  513. * @since 2.0.0
  514. *
  515. * @param array $media Array of images that would be good for a specific post.
  516. * @param int $post_id Post ID.
  517. * @param array $args Array of options to get images.
  518. */
  519. return apply_filters( 'jetpack_images_get_images', $media, $post_id, $args );
  520. }
  521. /**
  522. * Takes an image URL and pixel dimensions then returns a URL for the
  523. * resized and cropped image.
  524. *
  525. * @param string $src
  526. * @param int $dimension
  527. * @return string Transformed image URL
  528. */
  529. static function fit_image_url( $src, $width, $height ) {
  530. $width = (int) $width;
  531. $height = (int) $height;
  532. if ( $width < 1 || $height < 1 ) {
  533. return $src;
  534. }
  535. // See if we should bypass WordPress.com SaaS resizing
  536. if ( has_filter( 'jetpack_images_fit_image_url_override' ) ) {
  537. /**
  538. * Filters the image URL used after dimensions are set by Photon.
  539. *
  540. * @since 3.3.0
  541. *
  542. * @param string $src Image URL.
  543. * @param int $width Image width.
  544. * @param int $width Image height.
  545. */
  546. return apply_filters( 'jetpack_images_fit_image_url_override', $src, $width, $height );
  547. }
  548. // If WPCOM hosted image use native transformations
  549. $img_host = parse_url( $src, PHP_URL_HOST );
  550. if ( '.files.wordpress.com' == substr( $img_host, -20 ) ) {
  551. return add_query_arg( array( 'w' => $width, 'h' => $height, 'crop' => 1 ), set_url_scheme( $src ) );
  552. }
  553. // Use Photon magic
  554. if( function_exists( 'jetpack_photon_url' ) ) {
  555. return jetpack_photon_url( $src, array( 'resize' => "$width,$height" ) );
  556. }
  557. // Arg... no way to resize image using WordPress.com infrastructure!
  558. return $src;
  559. }
  560. }