PluginProbe ʕ •ᴥ•ʔ
Modern Image Formats / 2.7.0
Modern Image Formats v2.7.0
2.7.0 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.1.0 1.1.1 2.0.0 2.0.1 2.0.2 2.1.0 2.2.0 2.3.0 2.4.0 2.5.0 2.5.1 2.6.0 2.6.1
webp-uploads / deprecated.php
webp-uploads Last commit date
deprecated.php 17 hours ago helper.php 17 hours ago hooks.php 17 hours ago image-edit.php 17 hours ago load.php 17 hours ago picture-element.php 17 hours ago readme.txt 17 hours ago rest-api.php 17 hours ago settings.php 17 hours ago uninstall.php 17 hours ago
deprecated.php
96 lines
1 <?php
2 /**
3 * Deprecated functions.
4 *
5 * @package webp-uploads
6 *
7 * @since 1.1.1
8 */
9
10 declare( strict_types = 1 );
11
12 // @codeCoverageIgnoreStart
13 if ( ! defined( 'ABSPATH' ) ) {
14 exit; // Exit if accessed directly.
15 }
16 // @codeCoverageIgnoreEnd
17
18 /**
19 * Returns the attachment sources array ordered by filesize.
20 *
21 * @since 1.0.0
22 * @deprecated This function is not used anymore as of Performance Lab 1.1.0 when this was still part of the WebP Uploads module. It should have been removed as part of <https://github.com/WordPress/performance/pull/302>.
23 *
24 * @param int $attachment_id The attachment ID.
25 * @param string $size The attachment size.
26 * @return array<string, array{ file: string, filesize: int }> The attachment sources array.
27 */
28 function webp_uploads_get_attachment_sources( int $attachment_id, string $size = 'thumbnail' ): array {
29 _deprecated_function( __FUNCTION__, 'Performance Lab 1.1.0' );
30
31 // Check for the sources attribute in attachment metadata.
32 $metadata = wp_get_attachment_metadata( $attachment_id );
33
34 // Return full image size sources.
35 if (
36 'full' === $size &&
37 isset( $metadata['sources'] ) &&
38 is_array( $metadata['sources'] ) &&
39 count( $metadata['sources'] ) > 0
40 ) {
41 return $metadata['sources'];
42 }
43
44 // Return the resized image sources.
45 if ( isset( $metadata['sizes'][ $size ]['sources'] ) && is_array( $metadata['sizes'][ $size ]['sources'] ) ) {
46 return $metadata['sizes'][ $size ]['sources'];
47 }
48
49 // Return an empty array if no sources found.
50 return array();
51 }
52
53 /**
54 * Adds custom styles to hide specific elements in media settings.
55 *
56 * @since 1.0.0
57 * @deprecated This function is not used as of Modern Image Formats versions 2.0.0.
58 */
59 function webp_uploads_media_setting_style(): void {
60 _deprecated_function( __FUNCTION__, 'Modern Image Formats 2.0.0' );
61
62 if ( is_multisite() ) {
63 return;
64 }
65 ?>
66 <style>
67 .form-table .perflab-generate-webp-and-jpeg th,
68 .form-table .perflab-generate-webp-and-jpeg td:not(.td-full) {
69 display: none;
70 }
71 </style>
72 <?php
73 }
74
75 /**
76 * Updates the references of the featured image to the new image format if available.
77 *
78 * @since 1.0.0
79 * @deprecated 2.7.0 Featured images are now rewritten through the `wp_get_attachment_image`
80 * filter; see webp_uploads_filter_wp_get_attachment_image().
81 *
82 * @param string $html The current HTML markup of the featured image.
83 * @param int $post_id The current post ID where the featured image is requested.
84 * @param int $attachment_id The ID of the attachment image.
85 * @return string The updated HTML markup.
86 */
87 function webp_uploads_update_featured_image( string $html, int $post_id, int $attachment_id ): string {
88 _deprecated_function( __FUNCTION__, 'Modern Image Formats 2.7.0', 'webp_uploads_filter_wp_get_attachment_image()' );
89
90 if ( webp_uploads_is_picture_element_enabled() ) {
91 return webp_uploads_wrap_image_in_picture( $html, 'post_thumbnail_html', $attachment_id );
92 }
93
94 return webp_uploads_img_tag_update_mime_type( $html, 'post_thumbnail_html', $attachment_id );
95 }
96