intermediate_image_sizes_advanced
最后更新于:2021-11-27 01:50:27
apply_filters( ‘intermediate_image_sizes_advanced’, array $new_sizes, array $image_meta, int $attachment_id )
Filters the image sizes automatically generated when uploading an image.
参数
- $new_sizes
-
(array)
Associative array of image sizes to be created. - $image_meta
-
(array)
The image meta data: width, height, file, sizes, etc. - $attachment_id
-
(int)
The attachment post ID for the image.
源文件
文件: gc-admin/includes/image.php
function gcdocs_disable_upload_sizes( $sizes, $image_meta ) { // Get filetype data. $filetype = gc_check_filetype( $image_meta['file'] ); $exclude_file_types = array( 'image/gif', ); // Check if file type is on exclude list if ( in_array( $filetype['type'], $exclude_file_types ) ) { $sizes = array(); } // 响应 sizes you want to create from image (None if image is gif.) return $sizes; } add_filter( 'intermediate_image_sizes_advanced', 'gcdocs_disable_upload_sizes', 10, 2 );