webp-uploads
Last commit date
deprecated.php
2 years ago
fallback.js
2 years ago
helper.php
2 years ago
hooks.php
2 years ago
image-edit.php
2 years ago
load.php
2 years ago
readme.txt
2 years ago
rest-api.php
2 years ago
settings.php
2 years ago
uninstall.php
2 years ago
deprecated.php
43 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Deprecated functions. |
| 4 | * |
| 5 | * @package webp-uploads |
| 6 | * |
| 7 | * @since 1.1.1 |
| 8 | */ |
| 9 | |
| 10 | if ( ! defined( 'ABSPATH' ) ) { |
| 11 | exit; // Exit if accessed directly. |
| 12 | } |
| 13 | |
| 14 | /** |
| 15 | * Returns the attachment sources array ordered by filesize. |
| 16 | * |
| 17 | * @since 1.0.0 |
| 18 | * @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>. |
| 19 | * |
| 20 | * @param int $attachment_id The attachment ID. |
| 21 | * @param string $size The attachment size. |
| 22 | * @return array<string, array{ file: string, filesize: int }> The attachment sources array. |
| 23 | */ |
| 24 | function webp_uploads_get_attachment_sources( int $attachment_id, string $size = 'thumbnail' ): array { |
| 25 | _deprecated_function( __FUNCTION__, 'Performance Lab 1.1.0' ); |
| 26 | |
| 27 | // Check for the sources attribute in attachment metadata. |
| 28 | $metadata = wp_get_attachment_metadata( $attachment_id ); |
| 29 | |
| 30 | // Return full image size sources. |
| 31 | if ( 'full' === $size && ! empty( $metadata['sources'] ) ) { |
| 32 | return $metadata['sources']; |
| 33 | } |
| 34 | |
| 35 | // Return the resized image sources. |
| 36 | if ( ! empty( $metadata['sizes'][ $size ]['sources'] ) ) { |
| 37 | return $metadata['sizes'][ $size ]['sources']; |
| 38 | } |
| 39 | |
| 40 | // Return an empty array if no sources found. |
| 41 | return array(); |
| 42 | } |
| 43 |