_wp_image_meta_replace_original()
Updates the attached file and image meta data when the original image was edited.
Внутренняя функция — эта функция рассчитана на использование самим ядром. Не рекомендуется использовать эту функцию в своем коде.
Хуков нет.
Возвращает
Массив
. The updated image meta data.
Использование
_wp_image_meta_replace_original( $saved_data, $original_file, $image_meta, $attachment_id );
- $saved_data(массив) (обязательный)
- The data returned from WP_Image_Editor after successfully saving an image.
- $original_file(строка) (обязательный)
- Path to the original file.
- $image_meta(массив) (обязательный)
- The image meta data.
- $attachment_id(int) (обязательный)
- The attachment post ID.
Список изменений
С версии 5.3.0 | Введена. |
С версии 6.0.0 | The $filesize value was added to the returned array. |
Код _wp_image_meta_replace_original() wp image meta replace original WP 6.5.2
function _wp_image_meta_replace_original( $saved_data, $original_file, $image_meta, $attachment_id ) { $new_file = $saved_data['path']; // Update the attached file meta. update_attached_file( $attachment_id, $new_file ); // Width and height of the new image. $image_meta['width'] = $saved_data['width']; $image_meta['height'] = $saved_data['height']; // Make the file path relative to the upload dir. $image_meta['file'] = _wp_relative_upload_path( $new_file ); // Add image file size. $image_meta['filesize'] = wp_filesize( $new_file ); // Store the original image file name in image_meta. $image_meta['original_image'] = wp_basename( $original_file ); return $image_meta; }