PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 16.2
Jetpack – WP Security, Backup, Speed, & Growth v16.2
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 14.1.1 14.2.2 All 502 releases
jetpack / class.jetpack-post-images.php

class.jetpack-post-images.php in Jetpack – WP Security, Backup, Speed, & Growth 16.2, at class.jetpack-post-images.php

294 lines 11.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
2 /**
3 * Useful for finding an image to display alongside/in representation of a specific post.
4 *
5 * @deprecated 15.7 Use Automattic\Jetpack\Post_Media\Images instead.
6 * @package automattic/jetpack
7 */
8
9 use Automattic\Jetpack\Post_Media\Images;
10
11 /**
12 * Useful for finding an image to display alongside/in representation of a specific post.
13 *
14 * Includes a few different methods, all of which return a similar-format array containing
15 * details of any images found. Everything can (should) be called statically, it's just a
16 * function-bucket. You can also call Jetpack_PostImages::get_image() to cycle through all of the methods until
17 * one of them finds something useful.
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
24 */
25 class Jetpack_PostImages {
26 /**
27 * If a slideshow is embedded within a post, then parse out the images involved and return them
28 *
29 * @deprecated 15.7 Use Automattic\Jetpack\Post_Media\Images::from_slideshow() instead.
30 *
31 * @param int $post_id Post ID.
32 * @param int $width Image width.
33 * @param int $height Image height.
34 * @return array Images.
35 */
36 public static function from_slideshow( $post_id, $width = 200, $height = 200 ) {
37 _deprecated_function( __METHOD__, '15.7', 'Automattic\Jetpack\Post_Media\Images::from_slideshow' );
38 return Images::from_slideshow( $post_id, $width, $height );
39 }
40
41 /**
42 * Filtering out images with broken URL from galleries.
43 *
44 * @deprecated 15.7 Use Automattic\Jetpack\Post_Media\Images::filter_gallery_urls() instead.
45 *
46 * @param array $galleries Galleries.
47 * @return array $filtered_galleries
48 */
49 public static function filter_gallery_urls( $galleries ) {
50 _deprecated_function( __METHOD__, '15.7', 'Automattic\Jetpack\Post_Media\Images::filter_gallery_urls' );
51 return Images::filter_gallery_urls( $galleries );
52 }
53
54 /**
55 * If a gallery is detected, then get all the images from it.
56 *
57 * @deprecated 15.7 Use Automattic\Jetpack\Post_Media\Images::from_gallery() instead.
58 *
59 * @param int $post_id Post ID.
60 * @param int $width Minimum image width to consider.
61 * @param int $height Minimum image height to consider.
62 * @return array Images.
63 */
64 public static function from_gallery( $post_id, $width = 200, $height = 200 ) {
65 _deprecated_function( __METHOD__, '15.7', 'Automattic\Jetpack\Post_Media\Images::from_gallery' );
66 return Images::from_gallery( $post_id, $width, $height );
67 }
68
69 /**
70 * Get attachment images for a specified post and return them. Also make sure
71 * their dimensions are at or above a required minimum.
72 *
73 * @deprecated 15.7 Use Automattic\Jetpack\Post_Media\Images::from_attachment() instead.
74 *
75 * @param int $post_id The post ID to check.
76 * @param int $width Image width.
77 * @param int $height Image height.
78 * @return array Containing details of the image, or empty array if none.
79 */
80 public static function from_attachment( $post_id, $width = 200, $height = 200 ) {
81 _deprecated_function( __METHOD__, '15.7', 'Automattic\Jetpack\Post_Media\Images::from_attachment' );
82 return Images::from_attachment( $post_id, $width, $height );
83 }
84
85 /**
86 * Check if a Featured Image is set for this post, and return it in a similar
87 * format to the other images?_from_*() methods.
88 *
89 * @deprecated 15.7 Use Automattic\Jetpack\Post_Media\Images::from_thumbnail() instead.
90 *
91 * @param int $post_id The post ID to check.
92 * @param int $width Image width.
93 * @param int $height Image height.
94 * @return array containing details of the Featured Image, or empty array if none.
95 */
96 public static function from_thumbnail( $post_id, $width = 200, $height = 200 ) {
97 _deprecated_function( __METHOD__, '15.7', 'Automattic\Jetpack\Post_Media\Images::from_thumbnail' );
98 return Images::from_thumbnail( $post_id, $width, $height );
99 }
100
101 /**
102 * Get images from Gutenberg Image blocks.
103 *
104 * @deprecated 15.7 Use Automattic\Jetpack\Post_Media\Images::from_blocks() instead.
105 *
106 * @param mixed $html_or_id The HTML string to parse for images, or a post id.
107 * @param int $width Minimum Image width.
108 * @param int $height Minimum Image height.
109 */
110 public static function from_blocks( $html_or_id, $width = 200, $height = 200 ) {
111 _deprecated_function( __METHOD__, '15.7', 'Automattic\Jetpack\Post_Media\Images::from_blocks' );
112 return Images::from_blocks( $html_or_id, $width, $height );
113 }
114
115 /**
116 * Very raw -- just parse the HTML and pull out any/all img tags and return their src
117 *
118 * @deprecated 15.7 Use Automattic\Jetpack\Post_Media\Images::from_html() instead.
119 *
120 * @param mixed $html_or_id The HTML string to parse for images, or a post id.
121 * @param int $width Minimum Image width.
122 * @param int $height Minimum Image height.
123 *
124 * @return array containing images
125 */
126 public static function from_html( $html_or_id, $width = 200, $height = 200 ) {
127 return Images::from_html( $html_or_id, $width, $height );
128 }
129
130 /**
131 * Data from blavatar.
132 *
133 * @deprecated 15.7 Use Automattic\Jetpack\Post_Media\Images::from_blavatar() instead.
134 *
135 * @param int $post_id The post ID to check.
136 * @param int $size Size.
137 * @return array containing details of the image, or empty array if none.
138 */
139 public static function from_blavatar( $post_id, $size = 96 ) {
140 _deprecated_function( __METHOD__, '15.7', 'Automattic\Jetpack\Post_Media\Images::from_blavatar' );
141 return Images::from_blavatar( $post_id, $size );
142 }
143
144 /**
145 * Gets a post image from the author avatar.
146 *
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.
152 * @return array containing details of the image, or empty array if none.
153 */
154 public static function from_gravatar( $post_id, $size = 96, $default = false ) {
155 _deprecated_function( __METHOD__, '15.7', 'Automattic\Jetpack\Post_Media\Images::from_gravatar' );
156 return Images::from_gravatar( $post_id, $size, $default );
157 }
158
159 /**
160 * Run through the different methods that we have available to try to find a single good
161 * display image for this post.
162 *
163 * @deprecated 15.7 Use Automattic\Jetpack\Post_Media\Images::get_image() instead.
164 *
165 * @param int $post_id Post ID.
166 * @param array $args Other arguments (currently width and height required for images where possible to determine).
167 * @return array|null containing details of the best image to be used, or null if no image is found.
168 */
169 public static function get_image( $post_id, $args = array() ) {
170 return Images::get_image( $post_id, $args );
171 }
172
173 /**
174 * Get an array containing a collection of possible images for this post, stopping once we hit a method
175 * that returns something useful.
176 *
177 * @deprecated 15.7 Use Automattic\Jetpack\Post_Media\Images::get_images() instead.
178 *
179 * @param int $post_id Post ID.
180 * @param array $args Optional args, see defaults list for details.
181 * @return array containing images that would be good for representing this post
182 */
183 public static function get_images( $post_id, $args = array() ) {
184 _deprecated_function( __METHOD__, '15.7', 'Automattic\Jetpack\Post_Media\Images::get_images' );
185 return Images::get_images( $post_id, $args );
186 }
187
188 /**
189 * Takes an image and base pixel dimensions and returns a srcset for the
190 * resized and cropped images, based on a fixed set of multipliers.
191 *
192 * @deprecated 15.7 Use Automattic\Jetpack\Post_Media\Images::generate_cropped_srcset() instead.
193 *
194 * @param array $image Array containing details of the image.
195 * @param int $base_width Base image width (i.e., the width at 1x).
196 * @param int $base_height Base image height (i.e., the height at 1x).
197 * @param bool $use_widths Whether to generate the srcset with widths instead of multipliers.
198 * @return string The srcset for the image.
199 */
200 public static function generate_cropped_srcset( $image, $base_width, $base_height, $use_widths = false ) {
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 );
203 }
204
205 /**
206 * Takes an image URL and pixel dimensions then returns a URL for the
207 * resized and cropped image.
208 *
209 * @deprecated 15.7 Use Automattic\Jetpack\Post_Media\Images::fit_image_url() instead.
210 *
211 * @param string $src Image URL.
212 * @param int $width Image width.
213 * @param int $height Image height.
214 * @return string Transformed image URL
215 */
216 public static function fit_image_url( $src, $width, $height ) {
217 return Images::fit_image_url( $src, $width, $height );
218 }
219
220 /**
221 * Get HTML from given post content.
222 *
223 * @deprecated 15.7 Use Automattic\Jetpack\Post_Media\Images::get_post_html() instead.
224 *
225 * @param mixed $html_or_id The HTML string to parse for images, or a post id.
226 *
227 * @return array $html_info {
228 * @type string $html Post content.
229 * @type string $post_url Post URL.
230 * }
231 */
232 public static function get_post_html( $html_or_id ) {
233 _deprecated_function( __METHOD__, '15.7', 'Automattic\Jetpack\Post_Media\Images::get_post_html' );
234 return Images::get_post_html( $html_or_id );
235 }
236
237 /**
238 * Get info about a WordPress attachment.
239 *
240 * @deprecated 15.7 Use Automattic\Jetpack\Post_Media\Images::get_attachment_data() instead.
241 *
242 * @param int $attachment_id Attachment ID.
243 * @param string $post_url URL of the post, if we have one.
244 * @param int $width Minimum Image width.
245 * @param int $height Minimum Image height.
246 * @return array|bool Image data or false if unavailable.
247 */
248 public static function get_attachment_data( $attachment_id, $post_url, $width, $height ) {
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 );
251 }
252
253 /**
254 * Get the alt text for an image or other media from the Media Library.
255 *
256 * @deprecated 15.7 Use Automattic\Jetpack\Post_Media\Images::get_alt_text() instead.
257 *
258 * @param int $attachment_id The Post ID of the media.
259 * @return string The alt text value or an empty string.
260 */
261 public static function get_alt_text( $attachment_id ) {
262 _deprecated_function( __METHOD__, '15.7', 'Automattic\Jetpack\Post_Media\Images::get_alt_text' );
263 return Images::get_alt_text( $attachment_id );
264 }
265
266 /**
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.
269 *
270 * @deprecated 15.7 Use Automattic\Jetpack\Post_Media\Images::determine_thumbnail_size_for_photon() instead.
271 *
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).
275 */
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 );
279 }
280
281 /**
282 * Function to provide the maximum dimension for a thumbnail image.
283 * Filterable via the `jetpack_post_images_max_dimension` filter.
284 *
285 * @deprecated 15.7 Use Automattic\Jetpack\Post_Media\Images::get_max_thumbnail_dimension() instead.
286 *
287 * @return int The maximum dimension for a thumbnail image.
288 */
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();
292 }
293 }
294