PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 16.3-a.1
Jetpack – WP Security, Backup, Speed, & Growth v16.3-a.1
16.3-a.3 16.3-a.1 16.2 16.2-beta 12.0.3 12.1.3 12.2.3 12.3.2 12.4.2 12.5.2 12.6.4 12.7.3 12.8.3 12.9.5 13.0.2 13.1.5 13.2.4 13.3.3 13.4.5 13.5.2 13.6.2 13.7.2 13.8.3 13.9.2 14.0.1 All 504 releases
← All changes | class.jetpack-post-images.php +82 -876 13.5.216.3-a.1 View file →
@@ -1,12 +1,13 @@
1 1 <?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
2 2 /**
3 3 * Useful for finding an image to display alongside/in representation of a specific post.
4 4 *
5 + * @deprecated 15.7 Use Automattic\Jetpack\Post_Media\Images instead.
5 6 * @package automattic/jetpack
6 7 */
7 8
8 -use Automattic\Jetpack\Image_CDN\Image_CDN_Core;
9 +use Automattic\Jetpack\Post_Media\Images;
9 10
10 11 /**
11 12 * Useful for finding an image to display alongside/in representation of a specific post.
12 13 *
@@ -15,13 +16,19 @@
15 16 * function-bucket. You can also call Jetpack_PostImages::get_image() to cycle through all of the methods until
16 17 * one of them finds something useful.
17 18 *
18 19 * This file is included verbatim in Jetpack
20 + *
21 + * @deprecated 15.7 Use Automattic\Jetpack\Post_Media\Images instead.
22 + *
23 + * @see Automattic\Jetpack\Post_Media\Images
19 24 */
20 25 class Jetpack_PostImages {
21 26 /**
22 27 * If a slideshow is embedded within a post, then parse out the images involved and return them
23 28 *
29 + * @deprecated 15.7 Use Automattic\Jetpack\Post_Media\Images::from_slideshow() instead.
30 + *
24 31 * @param int $post_id Post ID.
25 32 * @param int $width Image width.
26 33 * @param int $height Image height.
27 34 * @return array Images.
@@ -26,121 +33,30 @@
26 33 * @param int $height Image height.
27 34 * @return array Images.
28 35 */
29 36 public static function from_slideshow( $post_id, $width = 200, $height = 200 ) {
30 - $images = array();
31 -
32 - $post = get_post( $post_id );
33 -
34 - if ( ! $post ) {
35 - return $images;
36 - }
37 -
38 - if ( ! empty( $post->post_password ) ) {
39 - return $images;
40 - }
41 -
42 - if ( false === has_shortcode( $post->post_content, 'slideshow' ) ) {
43 - return $images; // no slideshow - bail.
44 - }
45 -
46 - $permalink = get_permalink( $post->ID );
47 -
48 - // Mechanic: Somebody set us up the bomb.
49 - $old_post = $GLOBALS['post'];
50 - $GLOBALS['post'] = $post; // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
51 - $old_shortcodes = $GLOBALS['shortcode_tags'];
52 - $GLOBALS['shortcode_tags'] = array( 'slideshow' => $old_shortcodes['slideshow'] ); // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
53 -
54 - // Find all the slideshows.
55 - preg_match_all( '/' . get_shortcode_regex() . '/sx', $post->post_content, $slideshow_matches, PREG_SET_ORDER );
56 -
57 - ob_start(); // The slideshow shortcode handler calls wp_print_scripts and wp_print_styles... not too happy about that.
58 -
59 - foreach ( $slideshow_matches as $slideshow_match ) {
60 - $slideshow = do_shortcode_tag( $slideshow_match );
61 - $pos = stripos( $slideshow, 'jetpack-slideshow' );
62 - if ( false === $pos ) { // must be something wrong - or we changed the output format in which case none of the following will work.
63 - continue;
64 - }
65 - $start = strpos( $slideshow, '[', $pos );
66 - $end = strpos( $slideshow, ']', $start );
67 - $post_images = json_decode( wp_specialchars_decode( str_replace( "'", '"', substr( $slideshow, $start, $end - $start + 1 ) ), ENT_QUOTES ) ); // parse via JSON
68 - // If the JSON didn't decode don't try and act on it.
69 - if ( is_array( $post_images ) ) {
70 - foreach ( $post_images as $post_image ) {
71 - $post_image_id = absint( $post_image->id );
72 - if ( ! $post_image_id ) {
73 - continue;
74 - }
75 -
76 - $meta = wp_get_attachment_metadata( $post_image_id );
77 -
78 - // Must be larger than 200x200 (or user-specified).
79 - if ( ! isset( $meta['width'] ) || $meta['width'] < $width ) {
80 - continue;
81 - }
82 - if ( ! isset( $meta['height'] ) || $meta['height'] < $height ) {
83 - continue;
84 - }
85 -
86 - $url = wp_get_attachment_url( $post_image_id );
87 -
88 - $images[] = array(
89 - 'type' => 'image',
90 - 'from' => 'slideshow',
91 - 'src' => $url,
92 - 'src_width' => $meta['width'],
93 - 'src_height' => $meta['height'],
94 - 'href' => $permalink,
95 - );
96 - }
97 - }
98 - }
99 - ob_end_clean();
100 -
101 - // Operator: Main screen turn on.
102 - $GLOBALS['shortcode_tags'] = $old_shortcodes; // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
103 - $GLOBALS['post'] = $old_post; // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
104 -
105 - return $images;
37 + _deprecated_function( __METHOD__, '15.7', 'Automattic\Jetpack\Post_Media\Images::from_slideshow' );
38 + return Images::from_slideshow( $post_id, $width, $height );
106 39 }
107 40
108 41 /**
109 42 * Filtering out images with broken URL from galleries.
110 43 *
44 + * @deprecated 15.7 Use Automattic\Jetpack\Post_Media\Images::filter_gallery_urls() instead.
45 + *
111 46 * @param array $galleries Galleries.
112 47 * @return array $filtered_galleries
113 48 */
114 49 public static function filter_gallery_urls( $galleries ) {
115 - $filtered_galleries = array();
116 - foreach ( $galleries as $this_gallery ) {
117 - if ( ! isset( $this_gallery['src'] ) ) {
118 - continue;
119 - }
120 - $ids = isset( $this_gallery['ids'] ) ? explode( ',', $this_gallery['ids'] ) : array();
121 - // Make sure 'src' array isn't associative and has no holes.
122 - $this_gallery['src'] = array_values( $this_gallery['src'] );
123 - foreach ( $this_gallery['src'] as $idx => $src_url ) {
124 - if ( filter_var( $src_url, FILTER_VALIDATE_URL, FILTER_FLAG_PATH_REQUIRED ) === false ) {
125 - unset( $this_gallery['src'][ $idx ] );
126 - unset( $ids[ $idx ] );
127 - }
128 - }
129 - if ( isset( $this_gallery['ids'] ) ) {
130 - $this_gallery['ids'] = implode( ',', $ids );
131 - }
132 - // Remove any holes we introduced.
133 - $this_gallery['src'] = array_values( $this_gallery['src'] );
134 - $filtered_galleries[] = $this_gallery;
135 - }
136 -
137 - return $filtered_galleries;
50 + _deprecated_function( __METHOD__, '15.7', 'Automattic\Jetpack\Post_Media\Images::filter_gallery_urls' );
51 + return Images::filter_gallery_urls( $galleries );
138 52 }
139 53
140 54 /**
141 55 * If a gallery is detected, then get all the images from it.
142 56 *
57 + * @deprecated 15.7 Use Automattic\Jetpack\Post_Media\Images::from_gallery() instead.
58 + *
143 59 * @param int $post_id Post ID.
144 60 * @param int $width Minimum image width to consider.
145 61 * @param int $height Minimum image height to consider.
146 62 * @return array Images.
@@ -145,92 +61,10 @@
145 61 * @param int $height Minimum image height to consider.
146 62 * @return array Images.
147 63 */
148 64 public static function from_gallery( $post_id, $width = 200, $height = 200 ) {
149 - $images = array();
150 -
151 - $post = get_post( $post_id );
152 -
153 - if ( ! $post ) {
154 - return $images;
155 - }
156 -
157 - if ( ! empty( $post->post_password ) ) {
158 - return $images;
159 - }
160 - add_filter( 'get_post_galleries', array( __CLASS__, 'filter_gallery_urls' ), 999999 );
161 -
162 - $permalink = get_permalink( $post->ID );
163 -
164 - /**
165 - * Juggle global post object because the gallery shortcode uses the
166 - * global object.
167 - *
168 - * See core ticket:
169 - * https://core.trac.wordpress.org/ticket/39304
170 - */
171 - // phpcs:disable WordPress.WP.GlobalVariablesOverride.Prohibited
172 - if ( isset( $GLOBALS['post'] ) ) {
173 - $juggle_post = $GLOBALS['post'];
174 - $GLOBALS['post'] = $post;
175 - $galleries = get_post_galleries( $post->ID, false );
176 - $GLOBALS['post'] = $juggle_post;
177 - } else {
178 - $GLOBALS['post'] = $post;
179 - $galleries = get_post_galleries( $post->ID, false );
180 - unset( $GLOBALS['post'] );
181 - }
182 - // phpcs:enable WordPress.WP.GlobalVariablesOverride.Prohibited
183 -
184 - foreach ( $galleries as $gallery ) {
185 - if ( ! empty( $gallery['ids'] ) ) {
186 - $image_ids = explode( ',', $gallery['ids'] );
187 - $image_size = isset( $gallery['size'] ) ? $gallery['size'] : 'thumbnail';
188 - foreach ( $image_ids as $image_id ) {
189 - $image = wp_get_attachment_image_src( $image_id, $image_size );
190 - $meta = wp_get_attachment_metadata( $image_id );
191 -
192 - if ( isset( $gallery['type'] ) && 'slideshow' === $gallery['type'] ) {
193 - // Must be larger than 200x200 (or user-specified).
194 - if ( ! isset( $meta['width'] ) || $meta['width'] < $width ) {
195 - continue;
196 - }
197 - if ( ! isset( $meta['height'] ) || $meta['height'] < $height ) {
198 - continue;
199 - }
200 - }
201 -
202 - if ( ! empty( $image[0] ) ) {
203 - list( $raw_src ) = explode( '?', $image[0] ); // pull off any Query string (?w=250).
204 - $raw_src = wp_specialchars_decode( $raw_src ); // rawify it.
205 - $raw_src = esc_url_raw( $raw_src ); // clean it.
206 - $images[] = array(
207 - 'type' => 'image',
208 - 'from' => 'gallery',
209 - 'src' => $raw_src,
210 - 'src_width' => $meta['width'] ?? 0,
211 - 'src_height' => $meta['height'] ?? 0,
212 - 'href' => $permalink,
213 - 'alt_text' => self::get_alt_text( $image_id ),
214 - );
215 - }
216 - }
217 - } elseif ( ! empty( $gallery['src'] ) ) {
218 - foreach ( $gallery['src'] as $src ) {
219 - list( $raw_src ) = explode( '?', $src ); // pull off any Query string (?w=250).
220 - $raw_src = wp_specialchars_decode( $raw_src ); // rawify it.
221 - $raw_src = esc_url_raw( $raw_src ); // clean it.
222 - $images[] = array(
223 - 'type' => 'image',
224 - 'from' => 'gallery',
225 - 'src' => $raw_src,
226 - 'href' => $permalink,
227 - );
228 - }
229 - }
230 - }
231 -
232 - return $images;
65 + _deprecated_function( __METHOD__, '15.7', 'Automattic\Jetpack\Post_Media\Images::from_gallery' );
66 + return Images::from_gallery( $post_id, $width, $height );
233 67 }
234 68
235 69 /**
236 70 * Get attachment images for a specified post and return them. Also make sure
@@ -235,8 +69,10 @@
235 69 /**
236 70 * Get attachment images for a specified post and return them. Also make sure
237 71 * their dimensions are at or above a required minimum.
238 72 *
73 + * @deprecated 15.7 Use Automattic\Jetpack\Post_Media\Images::from_attachment() instead.
74 + *
239 75 * @param int $post_id The post ID to check.
240 76 * @param int $width Image width.
241 77 * @param int $height Image height.
242 78 * @return array Containing details of the image, or empty array if none.
@@ -241,69 +77,10 @@
241 77 * @param int $height Image height.
242 78 * @return array Containing details of the image, or empty array if none.
243 79 */
244 80 public static function from_attachment( $post_id, $width = 200, $height = 200 ) {
245 - $images = array();
246 -
247 - $post = get_post( $post_id );
248 -
249 - if ( ! empty( $post->post_password ) ) {
250 - return $images;
251 - }
252 -
253 - $post_images = get_posts(
254 - array(
255 - 'post_parent' => $post_id, // Must be children of post.
256 - 'numberposts' => 5, // No more than 5.
257 - 'post_type' => 'attachment', // Must be attachments.
258 - 'post_mime_type' => 'image', // Must be images.
259 - 'suppress_filters' => false,
260 - )
261 - );
262 -
263 - if ( ! $post_images ) {
264 - return $images;
265 - }
266 -
267 - $permalink = get_permalink( $post_id );
268 -
269 - foreach ( $post_images as $post_image ) {
270 - $current_image = self::get_attachment_data( $post_image->ID, $permalink, $width, $height );
271 - if ( false !== $current_image ) {
272 - $images[] = $current_image;
273 - }
274 - }
275 -
276 - /*
277 - * We only want to pass back attached images that were actually inserted.
278 - * We can load up all the images found in the HTML source and then
279 - * compare URLs to see if an image is attached AND inserted.
280 - */
281 - $html_images = self::from_html( $post_id );
282 - $inserted_images = array();
283 -
284 - foreach ( $html_images as $html_image ) {
285 - $src = wp_parse_url( $html_image['src'] );
286 - if ( ! $src ) {
287 - continue;
288 - }
289 -
290 - // strip off any query strings from src.
291 - if ( ! empty( $src['scheme'] ) && ! empty( $src['host'] ) ) {
292 - $inserted_images[] = $src['scheme'] . '://' . $src['host'] . $src['path'];
293 - } elseif ( ! empty( $src['host'] ) ) {
294 - $inserted_images[] = set_url_scheme( 'http://' . $src['host'] . $src['path'] );
295 - } else {
296 - $inserted_images[] = site_url( '/' ) . $src['path'];
297 - }
298 - }
299 - foreach ( $images as $i => $image ) {
300 - if ( ! in_array( $image['src'], $inserted_images, true ) ) {
301 - unset( $images[ $i ] );
302 - }
303 - }
304 -
305 - return $images;
81 + _deprecated_function( __METHOD__, '15.7', 'Automattic\Jetpack\Post_Media\Images::from_attachment' );
82 + return Images::from_attachment( $post_id, $width, $height );
306 83 }
307 84
308 85 /**
309 86 * Check if a Featured Image is set for this post, and return it in a similar
@@ -308,8 +85,10 @@
308 85 /**
309 86 * Check if a Featured Image is set for this post, and return it in a similar
310 87 * format to the other images?_from_*() methods.
311 88 *
89 + * @deprecated 15.7 Use Automattic\Jetpack\Post_Media\Images::from_thumbnail() instead.
90 + *
312 91 * @param int $post_id The post ID to check.
313 92 * @param int $width Image width.
314 93 * @param int $height Image height.
315 94 * @return array containing details of the Featured Image, or empty array if none.
@@ -314,110 +93,16 @@
314 93 * @param int $height Image height.
315 94 * @return array containing details of the Featured Image, or empty array if none.
316 95 */
317 96 public static function from_thumbnail( $post_id, $width = 200, $height = 200 ) {
318 - $images = array();
319 -
320 - $post = get_post( $post_id );
321 -
322 - if ( ! empty( $post->post_password ) ) {
323 - return $images;
324 - }
325 -
326 - if ( 'attachment' === get_post_type( $post ) && wp_attachment_is_image( $post ) ) {
327 - $thumb = $post_id;
328 - } else {
329 - $thumb = get_post_thumbnail_id( $post );
330 - }
331 -
332 - if ( $thumb ) {
333 - $meta = wp_get_attachment_metadata( $thumb );
334 - // Must be larger than requested minimums.
335 - if ( ! isset( $meta['width'] ) || $meta['width'] < $width ) {
336 - return $images;
337 - }
338 - if ( ! isset( $meta['height'] ) || $meta['height'] < $height ) {
339 - return $images;
340 - }
341 -
342 - $too_big = ( ( ! empty( $meta['width'] ) && $meta['width'] > 1200 ) || ( ! empty( $meta['height'] ) && $meta['height'] > 1200 ) );
343 -
344 - if (
345 - $too_big &&
346 - (
347 - ( method_exists( 'Jetpack', 'is_module_active' ) && Jetpack::is_module_active( 'photon' ) ) ||
348 - ( defined( 'IS_WPCOM' ) && IS_WPCOM )
349 - )
350 - ) {
351 - $img_src = wp_get_attachment_image_src( $thumb, array( 1200, 1200 ) );
352 - } else {
353 - $img_src = wp_get_attachment_image_src( $thumb, 'full' );
354 - }
355 - if ( ! is_array( $img_src ) ) {
356 - // If wp_get_attachment_image_src returns false but we know that there should be an image that could be used.
357 - // we try a bit harder and user the data that we have.
358 - $thumb_post_data = get_post( $thumb );
359 - $img_src = array( $thumb_post_data->guid ?? null, $meta['width'], $meta['height'] );
360 - }
361 -
362 - // Let's try to use the postmeta if we can, since it seems to be
363 - // more reliable
364 - if ( defined( 'IS_WPCOM' ) && IS_WPCOM ) {
365 - $featured_image = get_post_meta( $post->ID, '_jetpack_featured_image' );
366 - if ( $featured_image ) {
367 - $url = $featured_image[0];
368 - } else {
369 - $url = $img_src[0];
370 - }
371 - } else {
372 - $url = $img_src[0];
373 - }
374 - $images = array(
375 - array( // Other methods below all return an array of arrays.
376 - 'type' => 'image',
377 - 'from' => 'thumbnail',
378 - 'src' => $url,
379 - 'src_width' => $img_src[1],
380 - 'src_height' => $img_src[2],
381 - 'href' => get_permalink( $thumb ),
382 - 'alt_text' => self::get_alt_text( $thumb ),
383 - ),
384 - );
385 -
386 - }
387 -
388 - if ( empty( $images ) && ( defined( 'IS_WPCOM' ) && IS_WPCOM ) ) {
389 - $meta_thumbnail = get_post_meta( $post_id, '_jetpack_post_thumbnail', true );
390 - if ( ! empty( $meta_thumbnail ) ) {
391 - if ( ! isset( $meta_thumbnail['width'] ) || $meta_thumbnail['width'] < $width ) {
392 - return $images;
393 - }
394 -
395 - if ( ! isset( $meta_thumbnail['height'] ) || $meta_thumbnail['height'] < $height ) {
396 - return $images;
397 - }
398 -
399 - $images = array(
400 - array( // Other methods below all return an array of arrays.
401 - 'type' => 'image',
402 - 'from' => 'thumbnail',
403 - 'src' => $meta_thumbnail['URL'],
404 - 'src_width' => $meta_thumbnail['width'],
405 - 'src_height' => $meta_thumbnail['height'],
406 - 'href' => $meta_thumbnail['URL'],
407 - 'alt_text' => self::get_alt_text( $thumb ),
408 - ),
409 - );
410 - }
411 - }
412 -
413 - return $images;
97 + _deprecated_function( __METHOD__, '15.7', 'Automattic\Jetpack\Post_Media\Images::from_thumbnail' );
98 + return Images::from_thumbnail( $post_id, $width, $height );
414 99 }
415 100
416 101 /**
417 102 * Get images from Gutenberg Image blocks.
418 103 *
419 - * @since 6.9.0
104 + * @deprecated 15.7 Use Automattic\Jetpack\Post_Media\Images::from_blocks() instead.
420 105 *
421 106 * @param mixed $html_or_id The HTML string to parse for images, or a post id.
422 107 * @param int $width Minimum Image width.
423 108 * @param int $height Minimum Image height.
@@ -422,252 +107,54 @@
422 107 * @param int $width Minimum Image width.
423 108 * @param int $height Minimum Image height.
424 109 */
425 110 public static function from_blocks( $html_or_id, $width = 200, $height = 200 ) {
426 - $images = array();
427 -
428 - $html_info = self::get_post_html( $html_or_id );
429 -
430 - if ( empty( $html_info['html'] ) ) {
431 - return $images;
432 - }
433 -
434 - // Look for block information in the HTML.
435 - $blocks = parse_blocks( $html_info['html'] );
436 - if ( empty( $blocks ) ) {
437 - return $images;
438 - }
439 -
440 - /*
441 - * Let's loop through our blocks.
442 - * Some blocks may include some other blocks. Let's go 2 levels deep to look for blocks
443 - * that we support and that may include images (see get_images_from_block)
444 - *
445 - * @to-do: instead of looping manually (that's a lot of if and loops), search recursively instead.
446 - */
447 - foreach ( $blocks as $block ) {
448 - if ( ! self::is_nested_block( $block ) || 'core/media-text' === $block['blockName'] ) {
449 - $images = self::get_images_from_block( $images, $block, $html_info, $width, $height );
450 - } else {
451 - foreach ( $block['innerBlocks'] as $inner_block ) {
452 - if ( ! self::is_nested_block( $inner_block ) ) {
453 - $images = self::get_images_from_block( $images, $inner_block, $html_info, $width, $height );
454 - } else {
455 - foreach ( $inner_block['innerBlocks'] as $inner_inner_block ) {
456 - $images = self::get_images_from_block( $images, $inner_inner_block, $html_info, $width, $height );
457 - }
458 - }
459 - }
460 - }
461 - }
462 -
463 - /**
464 - * Returning a filtered array because get_attachment_data returns false
465 - * for unsuccessful attempts.
466 - */
467 - return array_filter( $images );
111 + _deprecated_function( __METHOD__, '15.7', 'Automattic\Jetpack\Post_Media\Images::from_blocks' );
112 + return Images::from_blocks( $html_or_id, $width, $height );
468 113 }
469 114
470 115 /**
471 116 * Very raw -- just parse the HTML and pull out any/all img tags and return their src
472 117 *
118 + * @deprecated 15.7 Use Automattic\Jetpack\Post_Media\Images::from_html() instead.
119 + *
473 120 * @param mixed $html_or_id The HTML string to parse for images, or a post id.
474 121 * @param int $width Minimum Image width.
475 122 * @param int $height Minimum Image height.
476 123 *
477 - * @uses DOMDocument
478 - *
479 124 * @return array containing images
480 125 */
481 126 public static function from_html( $html_or_id, $width = 200, $height = 200 ) {
482 - $images = array();
483 -
484 - $html_info = self::get_post_html( $html_or_id );
485 -
486 - if ( empty( $html_info['html'] ) ) {
487 - return $images;
488 - }
489 -
490 - // Do not go any further if DOMDocument is disabled on the server.
491 - if ( ! class_exists( 'DOMDocument' ) ) {
492 - return $images;
493 - }
494 -
495 - // Let's grab all image tags from the HTML.
496 - $dom_doc = new DOMDocument();
497 -
498 - // The @ is not enough to suppress errors when dealing with libxml,
499 - // we have to tell it directly how we want to handle errors.
500 - libxml_use_internal_errors( true );
501 - @$dom_doc->loadHTML( $html_info['html'] ); // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged
502 - libxml_use_internal_errors( false );
503 -
504 - $image_tags = $dom_doc->getElementsByTagName( 'img' );
505 -
506 - // For each image Tag, make sure it can be added to the $images array, and add it.
507 - foreach ( $image_tags as $image_tag ) {
508 - $img_src = $image_tag->getAttribute( 'src' );
509 -
510 - if ( empty( $img_src ) ) {
511 - continue;
512 - }
513 -
514 - // Do not grab smiley images that were automatically created by WP when entering text smilies.
515 - if ( stripos( $img_src, '/smilies/' ) ) {
516 - continue;
517 - }
518 - // First try to get the width and height from the img attributes, but if they are not set, check to see if they are specified in the url. WordPress automatically names files like foo-1024x768.jpg during the upload process
519 - $width = (int) $image_tag->getAttribute( 'width' );
520 - $height = (int) $image_tag->getAttribute( 'height' );
521 - if ( 0 === $width && 0 === $height ) {
522 - preg_match( '/-([0-9]{1,5})x([0-9]{1,5})\.(?:jpg|jpeg|png|gif|webp)$/i', $img_src, $matches );
523 - if ( ! empty( $matches[1] ) ) {
524 - $width = (int) $matches[1];
525 - }
526 - if ( ! empty( $matches[2] ) ) {
527 - $height = (int) $matches[2];
528 - }
529 - }
530 - // If width and height are still 0, try to get the id of the image from the class, e.g. wp-image-1234
531 - if ( 0 === $width && 0 === $height ) {
532 -
533 - preg_match( '/wp-image-([0-9]+)/', $image_tag->getAttribute( 'class' ), $matches );
534 - if ( ! empty( $matches[1] ) ) {
535 - $attachment_id = $matches[1];
536 - $meta = wp_get_attachment_metadata( $attachment_id );
537 - $height = $meta['height'] ?? 0;
538 - $width = $meta['width'] ?? 0;
539 - }
540 - }
541 -
542 - $meta = array(
543 - 'width' => $width,
544 - 'height' => $height,
545 - 'alt_text' => $image_tag->getAttribute( 'alt' ),
546 - );
547 -
548 - /**
549 - * Filters the switch to ignore minimum image size requirements. Can be used
550 - * to add custom logic to image dimensions, like only enforcing one of the dimensions,
551 - * or disabling it entirely.
552 - *
553 - * @since 6.4.0
554 - *
555 - * @param bool $ignore Should the image dimensions be ignored?
556 - * @param array $meta Array containing image dimensions parsed from the markup.
557 - */
558 - $ignore_dimensions = apply_filters( 'jetpack_postimages_ignore_minimum_dimensions', false, $meta );
559 -
560 - // Must be larger than 200x200 (or user-specified).
561 - if (
562 - ! $ignore_dimensions
563 - && (
564 - empty( $meta['width'] )
565 - || empty( $meta['height'] )
566 - || $meta['width'] < $width
567 - || $meta['height'] < $height
568 - )
569 - ) {
570 - continue;
571 - }
572 -
573 - $image = array(
574 - 'type' => 'image',
575 - 'from' => 'html',
576 - 'src' => $img_src,
577 - 'src_width' => $meta['width'],
578 - 'src_height' => $meta['height'],
579 - 'href' => $html_info['post_url'],
580 - );
581 - if ( ! empty( $meta['alt_text'] ) ) {
582 - $image['alt_text'] = $meta['alt_text'];
583 - }
584 - $images[] = $image;
585 - }
586 - return $images;
127 + return Images::from_html( $html_or_id, $width, $height );
587 128 }
588 129
589 130 /**
590 131 * Data from blavatar.
591 132 *
133 + * @deprecated 15.7 Use Automattic\Jetpack\Post_Media\Images::from_blavatar() instead.
134 + *
592 135 * @param int $post_id The post ID to check.
593 136 * @param int $size Size.
594 137 * @return array containing details of the image, or empty array if none.
595 138 */
596 139 public static function from_blavatar( $post_id, $size = 96 ) {
597 -
598 - $permalink = get_permalink( $post_id );
599 -
600 - if ( function_exists( 'blavatar_domain' ) && function_exists( 'blavatar_exists' ) && function_exists( 'blavatar_url' ) ) {
601 - $domain = blavatar_domain( $permalink );
602 -
603 - if ( ! blavatar_exists( $domain ) ) {
604 - return array();
605 - }
606 -
607 - $url = blavatar_url( $domain, 'img', $size );
608 - } else {
609 - $url = get_site_icon_url( $size );
610 - if ( ! $url ) {
611 - return array();
612 - }
613 - }
614 -
615 - return array(
616 - array(
617 - 'type' => 'image',
618 - 'from' => 'blavatar',
619 - 'src' => $url,
620 - 'src_width' => $size,
621 - 'src_height' => $size,
622 - 'href' => $permalink,
623 - 'alt_text' => '',
624 - ),
625 - );
140 + _deprecated_function( __METHOD__, '15.7', 'Automattic\Jetpack\Post_Media\Images::from_blavatar' );
141 + return Images::from_blavatar( $post_id, $size );
626 142 }
627 143
628 144 /**
629 145 * Gets a post image from the author avatar.
630 146 *
631 - * @param int $post_id The post ID to check.
632 - * @param int $size The size of the avatar to get.
633 - * @param string $default The default image to use.
147 + * @deprecated 15.7 Use Automattic\Jetpack\Post_Media\Images::from_gravatar() instead.
148 + *
149 + * @param int $post_id The post ID to check.
150 + * @param int $size The size of the avatar to get.
151 + * @param string|false $default The default image to use.
634 152 * @return array containing details of the image, or empty array if none.
635 153 */
636 154 public static function from_gravatar( $post_id, $size = 96, $default = false ) {
637 - $post = get_post( $post_id );
638 - $permalink = get_permalink( $post_id );
639 -
640 - if ( ! $post instanceof WP_Post ) {
641 - return array();
642 - }
643 -
644 - if ( function_exists( 'wpcom_get_avatar_url' ) ) {
645 - $url = wpcom_get_avatar_url( $post->post_author, $size, $default, true );
646 - if ( $url && is_array( $url ) ) {
647 - $url = $url[0];
648 - }
649 - } else {
650 - $url = get_avatar_url(
651 - $post->post_author,
652 - array(
653 - 'size' => $size,
654 - 'default' => $default,
655 - )
656 - );
657 - }
658 -
659 - return array(
660 - array(
661 - 'type' => 'image',
662 - 'from' => 'gravatar',
663 - 'src' => $url,
664 - 'src_width' => $size,
665 - 'src_height' => $size,
666 - 'href' => $permalink,
667 - 'alt_text' => '',
668 - ),
669 - );
155 + _deprecated_function( __METHOD__, '15.7', 'Automattic\Jetpack\Post_Media\Images::from_gravatar' );
156 + return Images::from_gravatar( $post_id, $size, $default );
670 157 }
671 158
672 159 /**
673 160 * Run through the different methods that we have available to try to find a single good
@@ -672,44 +159,16 @@
672 159 /**
673 160 * Run through the different methods that we have available to try to find a single good
674 161 * display image for this post.
675 162 *
163 + * @deprecated 15.7 Use Automattic\Jetpack\Post_Media\Images::get_image() instead.
164 + *
676 165 * @param int $post_id Post ID.
677 166 * @param array $args Other arguments (currently width and height required for images where possible to determine).
678 167 * @return array|null containing details of the best image to be used, or null if no image is found.
679 168 */
680 169 public static function get_image( $post_id, $args = array() ) {
681 - $image = null;
682 -
683 - /**
684 - * Fires before we find a single good image for a specific post.
685 - *
686 - * @since 2.2.0
687 - *
688 - * @param int $post_id Post ID.
689 - */
690 - do_action( 'jetpack_postimages_pre_get_image', $post_id );
691 - $media = self::get_images( $post_id, $args );
692 -
693 - if ( is_array( $media ) ) {
694 - foreach ( $media as $item ) {
695 - if ( 'image' === $item['type'] ) {
696 - $image = $item;
697 - break;
698 - }
699 - }
700 - }
701 -
702 - /**
703 - * Fires after we find a single good image for a specific post.
704 - *
705 - * @since 2.2.0
706 - *
707 - * @param int $post_id Post ID.
708 - */
709 - do_action( 'jetpack_postimages_post_get_image', $post_id );
710 -
711 - return $image;
170 + return Images::get_image( $post_id, $args );
712 171 }
713 172
714 173 /**
715 174 * Get an array containing a collection of possible images for this post, stopping once we hit a method
@@ -714,96 +173,17 @@
714 173 /**
715 174 * Get an array containing a collection of possible images for this post, stopping once we hit a method
716 175 * that returns something useful.
717 176 *
177 + * @deprecated 15.7 Use Automattic\Jetpack\Post_Media\Images::get_images() instead.
178 + *
718 179 * @param int $post_id Post ID.
719 180 * @param array $args Optional args, see defaults list for details.
720 181 * @return array containing images that would be good for representing this post
721 182 */
722 183 public static function get_images( $post_id, $args = array() ) {
723 - // Figure out which image to attach to this post.
724 - $media = array();
725 -
726 - /**
727 - * Filters the array of images that would be good for a specific post.
728 - * This filter is applied before options ($args) filter the original array.
729 - *
730 - * @since 2.0.0
731 - *
732 - * @param array $media Array of images that would be good for a specific post.
733 - * @param int $post_id Post ID.
734 - * @param array $args Array of options to get images.
735 - */
736 - $media = apply_filters( 'jetpack_images_pre_get_images', $media, $post_id, $args );
737 - if ( $media ) {
738 - return $media;
739 - }
740 -
741 - $defaults = array(
742 - 'width' => 200, // Required minimum width (if possible to determine).
743 - 'height' => 200, // Required minimum height (if possible to determine).
744 -
745 - 'fallback_to_avatars' => false, // Optionally include Blavatar and Gravatar (in that order) in the image stack.
746 - 'avatar_size' => 96, // Used for both Grav and Blav.
747 - 'gravatar_default' => false, // Default image to use if we end up with no Gravatar.
748 -
749 - 'from_thumbnail' => true, // Use these flags to specify which methods to use to find an image.
750 - 'from_slideshow' => true,
751 - 'from_gallery' => true,
752 - 'from_attachment' => true,
753 - 'from_blocks' => true,
754 - 'from_html' => true,
755 -
756 - 'html_content' => '', // HTML string to pass to from_html().
757 - );
758 - $args = wp_parse_args( $args, $defaults );
759 -
760 - $media = array();
761 - if ( $args['from_thumbnail'] ) {
762 - $media = self::from_thumbnail( $post_id, $args['width'], $args['height'] );
763 - }
764 - if ( ! $media && $args['from_slideshow'] ) {
765 - $media = self::from_slideshow( $post_id, $args['width'], $args['height'] );
766 - }
767 - if ( ! $media && $args['from_gallery'] ) {
768 - $media = self::from_gallery( $post_id );
769 - }
770 - if ( ! $media && $args['from_attachment'] ) {
771 - $media = self::from_attachment( $post_id, $args['width'], $args['height'] );
772 - }
773 - if ( ! $media && $args['from_blocks'] ) {
774 - if ( empty( $args['html_content'] ) ) {
775 - $media = self::from_blocks( $post_id, $args['width'], $args['height'] ); // Use the post_id, which will load the content.
776 - } else {
777 - $media = self::from_blocks( $args['html_content'], $args['width'], $args['height'] ); // If html_content is provided, use that.
778 - }
779 - }
780 - if ( ! $media && $args['from_html'] ) {
781 - if ( empty( $args['html_content'] ) ) {
782 - $media = self::from_html( $post_id, $args['width'], $args['height'] ); // Use the post_id, which will load the content.
783 - } else {
784 - $media = self::from_html( $args['html_content'], $args['width'], $args['height'] ); // If html_content is provided, use that.
785 - }
786 - }
787 -
788 - if ( ! $media && $args['fallback_to_avatars'] ) {
789 - $media = self::from_blavatar( $post_id, $args['avatar_size'] );
790 - if ( ! $media ) {
791 - $media = self::from_gravatar( $post_id, $args['avatar_size'], $args['gravatar_default'] );
792 - }
793 - }
794 -
795 - /**
796 - * Filters the array of images that would be good for a specific post.
797 - * This filter is applied after options ($args) filter the original array.
798 - *
799 - * @since 2.0.0
800 - *
801 - * @param array $media Array of images that would be good for a specific post.
802 - * @param int $post_id Post ID.
803 - * @param array $args Array of options to get images.
804 - */
805 - return apply_filters( 'jetpack_images_get_images', $media, $post_id, $args );
184 + _deprecated_function( __METHOD__, '15.7', 'Automattic\Jetpack\Post_Media\Images::get_images' );
185 + return Images::get_images( $post_id, $args );
806 186 }
807 187
808 188 /**
809 189 * Takes an image and base pixel dimensions and returns a srcset for the
@@ -808,8 +188,10 @@
808 188 /**
809 189 * Takes an image and base pixel dimensions and returns a srcset for the
810 190 * resized and cropped images, based on a fixed set of multipliers.
811 191 *
192 + * @deprecated 15.7 Use Automattic\Jetpack\Post_Media\Images::generate_cropped_srcset() instead.
193 + *
812 194 * @param array $image Array containing details of the image.
813 195 * @param int $base_width Base image width (i.e., the width at 1x).
814 196 * @param int $base_height Base image height (i.e., the height at 1x).
815 197 * @param bool $use_widths Whether to generate the srcset with widths instead of multipliers.
@@ -815,41 +197,10 @@
815 197 * @param bool $use_widths Whether to generate the srcset with widths instead of multipliers.
816 198 * @return string The srcset for the image.
817 199 */
818 200 public static function generate_cropped_srcset( $image, $base_width, $base_height, $use_widths = false ) {
819 - $srcset = '';
820 -
821 - if ( ! is_array( $image ) || empty( $image['src'] ) || empty( $image['src_width'] ) ) {
822 - return $srcset;
823 - }
824 -
825 - $multipliers = array( 1, 1.5, 2, 3, 4 );
826 - $srcset_values = array();
827 - foreach ( $multipliers as $multiplier ) {
828 - $srcset_width = (int) ( $base_width * $multiplier );
829 - $srcset_height = (int) ( $base_height * $multiplier );
830 - if ( $srcset_width < 1 || $srcset_width > $image['src_width'] ) {
831 - break;
832 - }
833 -
834 - $srcset_url = self::fit_image_url(
835 - $image['src'],
836 - $srcset_width,
837 - $srcset_height
838 - );
839 -
840 - if ( $use_widths ) {
841 - $srcset_values[] = "{$srcset_url} {$srcset_width}w";
842 - } else {
843 - $srcset_values[] = "{$srcset_url} {$multiplier}x";
844 - }
845 - }
846 -
847 - if ( count( $srcset_values ) > 1 ) {
848 - $srcset = implode( ', ', $srcset_values );
849 - }
850 -
851 - return $srcset;
201 + _deprecated_function( __METHOD__, '15.7', 'Automattic\Jetpack\Post_Media\Images::generate_cropped_srcset' );
202 + return Images::generate_cropped_srcset( $image, $base_width, $base_height, $use_widths );
852 203 }
853 204
854 205 /**
855 206 * Takes an image URL and pixel dimensions then returns a URL for the
@@ -854,8 +205,10 @@
854 205 /**
855 206 * Takes an image URL and pixel dimensions then returns a URL for the
856 207 * resized and cropped image.
857 208 *
209 + * @deprecated 15.7 Use Automattic\Jetpack\Post_Media\Images::fit_image_url() instead.
210 + *
858 211 * @param string $src Image URL.
859 212 * @param int $width Image width.
860 213 * @param int $height Image height.
861 214 * @return string Transformed image URL
@@ -860,55 +213,15 @@
860 213 * @param int $height Image height.
861 214 * @return string Transformed image URL
862 215 */
863 216 public static function fit_image_url( $src, $width, $height ) {
864 - $width = (int) $width;
865 - $height = (int) $height;
866 -
867 - if ( $width < 1 || $height < 1 ) {
868 - return $src;
869 - }
870 -
871 - // See if we should bypass WordPress.com SaaS resizing.
872 - if ( has_filter( 'jetpack_images_fit_image_url_override' ) ) {
873 - /**
874 - * Filters the image URL used after dimensions are set by Photon.
875 - *
876 - * @since 3.3.0
877 - *
878 - * @param string $src Image URL.
879 - * @param int $width Image width.
880 - * @param int $width Image height.
881 - */
882 - return apply_filters( 'jetpack_images_fit_image_url_override', $src, $width, $height );
883 - }
884 -
885 - // If WPCOM hosted image use native transformations.
886 - $img_host = wp_parse_url( $src, PHP_URL_HOST );
887 - if ( str_ends_with( $img_host, '.files.wordpress.com' ) ) {
888 - return add_query_arg(
889 - array(
890 - 'w' => $width,
891 - 'h' => $height,
892 - 'crop' => 1,
893 - ),
894 - set_url_scheme( $src )
895 - );
896 - }
897 -
898 - // Use image cdn magic.
899 - if ( class_exists( Image_CDN_Core::class ) && method_exists( Image_CDN_Core::class, 'cdn_url' ) ) {
900 - return Image_CDN_Core::cdn_url( $src, array( 'resize' => "$width,$height" ) );
901 - }
902 -
903 - // Arg... no way to resize image using WordPress.com infrastructure!
904 - return $src;
217 + return Images::fit_image_url( $src, $width, $height );
905 218 }
906 219
907 220 /**
908 221 * Get HTML from given post content.
909 222 *
910 - * @since 6.9.0
223 + * @deprecated 15.7 Use Automattic\Jetpack\Post_Media\Images::get_post_html() instead.
911 224 *
912 225 * @param mixed $html_or_id The HTML string to parse for images, or a post id.
913 226 *
914 227 * @return array $html_info {
@@ -916,32 +229,16 @@
916 229 * @type string $post_url Post URL.
917 230 * }
918 231 */
919 232 public static function get_post_html( $html_or_id ) {
920 - if ( is_numeric( $html_or_id ) ) {
921 - $post = get_post( $html_or_id );
922 -
923 - if ( empty( $post ) || ! empty( $post->post_password ) ) {
924 - return '';
925 - }
926 -
927 - $html_info = array(
928 - 'html' => $post->post_content, // DO NOT apply the_content filters here, it will cause loops.
929 - 'post_url' => get_permalink( $post->ID ),
930 - );
931 - } else {
932 - $html_info = array(
933 - 'html' => $html_or_id,
934 - 'post_url' => '',
935 - );
936 - }
937 - return $html_info;
233 + _deprecated_function( __METHOD__, '15.7', 'Automattic\Jetpack\Post_Media\Images::get_post_html' );
234 + return Images::get_post_html( $html_or_id );
938 235 }
939 236
940 237 /**
941 238 * Get info about a WordPress attachment.
942 239 *
943 - * @since 6.9.0
240 + * @deprecated 15.7 Use Automattic\Jetpack\Post_Media\Images::get_attachment_data() instead.
944 241 *
945 242 * @param int $attachment_id Attachment ID.
946 243 * @param string $post_url URL of the post, if we have one.
947 244 * @param int $width Minimum Image width.
@@ -948,140 +245,49 @@
948 245 * @param int $height Minimum Image height.
949 246 * @return array|bool Image data or false if unavailable.
950 247 */
951 248 public static function get_attachment_data( $attachment_id, $post_url, $width, $height ) {
952 - if ( empty( $attachment_id ) ) {
953 - return false;
954 - }
955 -
956 - $meta = wp_get_attachment_metadata( $attachment_id );
957 -
958 - if ( empty( $meta ) ) {
959 - return false;
960 - }
961 -
962 - if ( ! empty( $meta['videopress'] ) ) {
963 - // Use poster image for VideoPress videos.
964 - $url = $meta['videopress']['poster'];
965 - $meta_width = $meta['videopress']['width'];
966 - $meta_height = $meta['videopress']['height'];
967 - } elseif ( ! empty( $meta['thumb'] ) ) {
968 - // On WordPress.com, VideoPress videos have a 'thumb' property with the
969 - // poster image filename instead.
970 - $media_url = wp_get_attachment_url( $attachment_id );
971 - $url = str_replace( wp_basename( $media_url ), $meta['thumb'], $media_url );
972 - $meta_width = $meta['width'];
973 - $meta_height = $meta['height'];
974 - } elseif ( wp_attachment_is( 'video', $attachment_id ) ) {
975 - // We don't have thumbnail images for non-VideoPress videos - skip them.
976 - return false;
977 - } else {
978 - if ( ! isset( $meta['width'] ) || ! isset( $meta['height'] ) ) {
979 - return false;
980 - }
981 - $url = wp_get_attachment_url( $attachment_id );
982 - $meta_width = $meta['width'];
983 - $meta_height = $meta['height'];
984 - }
985 -
986 - if ( $meta_width < $width || $meta_height < $height ) {
987 - return false;
988 - }
989 -
990 - return array(
991 - 'type' => 'image',
992 - 'from' => 'attachment',
993 - 'src' => $url,
994 - 'src_width' => $meta_width,
995 - 'src_height' => $meta_height,
996 - 'href' => $post_url,
997 - 'alt_text' => self::get_alt_text( $attachment_id ),
998 - );
249 + _deprecated_function( __METHOD__, '15.7', 'Automattic\Jetpack\Post_Media\Images::get_attachment_data' );
250 + return Images::get_attachment_data( $attachment_id, $post_url, $width, $height );
999 251 }
1000 252
1001 253 /**
1002 254 * Get the alt text for an image or other media from the Media Library.
1003 255 *
1004 - * @since 7.1
256 + * @deprecated 15.7 Use Automattic\Jetpack\Post_Media\Images::get_alt_text() instead.
1005 257 *
1006 258 * @param int $attachment_id The Post ID of the media.
1007 259 * @return string The alt text value or an empty string.
1008 260 */
1009 261 public static function get_alt_text( $attachment_id ) {
1010 - return (string) get_post_meta( $attachment_id, '_wp_attachment_image_alt', true );
262 + _deprecated_function( __METHOD__, '15.7', 'Automattic\Jetpack\Post_Media\Images::get_alt_text' );
263 + return Images::get_alt_text( $attachment_id );
1011 264 }
1012 265
1013 266 /**
1014 - * Get an image from a block.
267 + * Determine the size to use with Photon for a thumbnail image.
268 + * Images larger than the maximum thumbnail dimension in either dimension are resized to maintain aspect ratio.
1015 269 *
1016 - * @since 7.8.0
270 + * @deprecated 15.7 Use Automattic\Jetpack\Post_Media\Images::determine_thumbnail_size_for_photon() instead.
1017 271 *
1018 - * @param array $images Images found.
1019 - * @param array $block Block and its attributes.
1020 - * @param array $html_info Info about the post where the block is found.
1021 - * @param int $width Desired image width.
1022 - * @param int $height Desired image height.
1023 - *
1024 - * @return array Array of images found.
272 + * @param int $width Original image width.
273 + * @param int $height Original image height.
274 + * @return array Array containing the width and height to use with Photon (null means auto).
1025 275 */
1026 - private static function get_images_from_block( $images, $block, $html_info, $width, $height ) {
1027 - /**
1028 - * Parse content from Core Image blocks.
1029 - * If it is an image block for an image hosted on our site, it will have an ID.
1030 - * If it does not have an ID, let `from_html` parse that content later,
1031 - * and extract an image if it has size parameters.
1032 - */
1033 - if (
1034 - 'core/image' === $block['blockName']
1035 - && ! empty( $block['attrs']['id'] )
1036 - ) {
1037 - $images[] = self::get_attachment_data( $block['attrs']['id'], $html_info['post_url'], $width, $height );
1038 - } elseif (
1039 - 'core/media-text' === $block['blockName']
1040 - && ! empty( $block['attrs']['mediaId'] )
1041 - ) {
1042 - $images[] = self::get_attachment_data( $block['attrs']['mediaId'], $html_info['post_url'], $width, $height );
1043 - } elseif (
1044 - /**
1045 - * Parse content from Core Gallery blocks as well from Jetpack's Tiled Gallery and Slideshow blocks.
1046 - * Gallery blocks include the ID of each one of the images in the gallery.
1047 - */
1048 - in_array( $block['blockName'], array( 'core/gallery', 'jetpack/tiled-gallery', 'jetpack/slideshow' ), true )
1049 - && ! empty( $block['attrs']['ids'] )
1050 - ) {
1051 - foreach ( $block['attrs']['ids'] as $img_id ) {
1052 - $images[] = self::get_attachment_data( $img_id, $html_info['post_url'], $width, $height );
1053 - }
1054 - } elseif (
1055 - /**
1056 - * Parse content from Jetpack's Story block.
1057 - */
1058 - 'jetpack/story' === $block['blockName']
1059 - && ! empty( $block['attrs']['mediaFiles'] )
1060 - ) {
1061 - foreach ( $block['attrs']['mediaFiles'] as $media_file ) {
1062 - if ( ! empty( $media_file['id'] ) ) {
1063 - $images[] = self::get_attachment_data( $media_file['id'], $html_info['post_url'], $width, $height );
1064 - }
1065 - }
1066 - }
1067 -
1068 - return $images;
276 + public static function determine_thumbnail_size_for_photon( $width, $height ) {
277 + _deprecated_function( __METHOD__, '15.7', 'Automattic\Jetpack\Post_Media\Images::determine_thumbnail_size_for_photon' );
278 + return Images::determine_thumbnail_size_for_photon( $width, $height );
1069 279 }
1070 280
1071 281 /**
1072 - * Check if a block has inner blocks.
282 + * Function to provide the maximum dimension for a thumbnail image.
283 + * Filterable via the `jetpack_post_images_max_dimension` filter.
1073 284 *
1074 - * @since 7.8.0
285 + * @deprecated 15.7 Use Automattic\Jetpack\Post_Media\Images::get_max_thumbnail_dimension() instead.
1075 286 *
1076 - * @param array $block Block and its attributes.
1077 - *
1078 - * @return bool
287 + * @return int The maximum dimension for a thumbnail image.
1079 288 */
1080 - private static function is_nested_block( $block ) {
1081 - if ( ! empty( $block['innerBlocks'] ) ) {
1082 - return true;
1083 - }
1084 -
1085 - return false;
289 + public static function get_max_thumbnail_dimension() {
290 + _deprecated_function( __METHOD__, '15.7', 'Automattic\Jetpack\Post_Media\Images::get_max_thumbnail_dimension' );
291 + return Images::get_max_thumbnail_dimension();
1086 292 }
1087 293 }