Bazujące na WordPress narzędzie wyszukiwania dla deweloperów i twórców motywów.



wp_update_image_subsizes ›

Od5.3.0
Przestarzałyn/a
wp_update_image_subsizes ( $attachment_id )
Parametry:
  • (int) $attachment_id The image attachment post ID.
    Wymagane: Tak
Powrót:
  • (array) The updated image meta data array.
Zdefiniowane na:
Codex:

If any of the currently registered image sub-sizes are missing, create them and update the image meta data.



Źródło

function wp_update_image_subsizes( $attachment_id ) {
	$missing_sizes = wp_get_missing_image_subsizes( $attachment_id );
	$image_meta    = wp_get_attachment_metadata( $attachment_id );

	if ( empty( $missing_sizes ) ) {
		return $image_meta;
	}

	$image_file = get_attached_file( $attachment_id );

	// This also updates the image meta.
	return _wp_make_subsizes( $missing_sizes, $image_file, $image_meta, $attachment_id );
}