wp_generate_attachment_metadata [ WordPress Function ]
wp_generate_attachment_metadata ( $attachment_id, $file )
| Parameters: |
|
| Returns: |
|
| Defined at: |
|
Benzer Fonksiyonlar: wp_get_attachment_metadata, wp_update_attachment_metadata, wp_get_attachment_image, wp_delete_attachment, wp_insert_attachment
Generate post thumbnail attachment meta data.
Source
<?php
function wp_generate_attachment_metadata( $attachment_id, $file ) {
$attachment = get_post( $attachment_id );
$metadata = array();
if ( preg_match('!^image/!', get_post_mime_type( $attachment )) && file_is_displayable_image($file) ) {
$imagesize = getimagesize( $file );
$metadata['width'] = $imagesize[0];
$metadata['height'] = $imagesize[1];
list($uwidth, $uheight) = wp_constrain_dimensions($metadata['width'], $metadata['height'], 128, 96);
$metadata['hwstring_small'] = "height='$uheight' width='$uwidth'";
// Make the file path relative to the upload dir
$metadata['file'] = _wp_relative_upload_path($file);
// make thumbnails and other intermediate sizes
global $_wp_additional_image_sizes;
foreach ( get_intermediate_image_sizes() as $s ) {
$sizes[$s] = array( 'width' => '', 'height' => '', 'crop' => false );
if ( isset( $_wp_additional_image_sizes[$s]['width'] ) )
$sizes[$s]['width'] = intval( $_wp_additional_image_sizes[$s]['width'] ); // For theme-added sizes
else
$sizes[$s]['width'] = get_option( "{$s}_size_w" ); // For default sizes set in options
if ( isset( $_wp_additional_image_sizes[$s]['height'] ) )
$sizes[$s]['height'] = intval( $_wp_additional_image_sizes[$s]['height'] ); // For theme-added sizes
else
$sizes[$s]['height'] = get_option( "{$s}_size_h" ); // For default sizes set in options
if ( isset( $_wp_additional_image_sizes[$s]['crop'] ) )
$sizes[$s]['crop'] = intval( $_wp_additional_image_sizes[$s]['crop'] ); // For theme-added sizes
else
$sizes[$s]['crop'] = get_option( "{$s}_crop" ); // For default sizes set in options
}
$sizes = apply_filters( 'intermediate_image_sizes_advanced', $sizes );
foreach ($sizes as $size => $size_data ) {
$resized = image_make_intermediate_size( $file, $size_data['width'], $size_data['height'], $size_data['crop'] );
if ( $resized )
$metadata['sizes'][$size] = $resized;
}
// fetch additional metadata from exif/iptc
$image_meta = wp_read_image_metadata( $file );
if ( $image_meta )
$metadata['image_meta'] = $image_meta;
}
return apply_filters( 'wp_generate_attachment_metadata', $metadata, $attachment_id );
}
?>
Examples [ wp-snippets.com ]
Google Arama Sonuçlarý
- Function Reference/wp generate attachment metadata « WordPress ...
Description. This function generates metadata for an image attachment. It also creates a thumbnail and other intermediate sizes of the image attachment based ...
codex.wordpress.org - undefined function wp_generate_attachment_metadata() - WordPress
I'm trying to use the function wp_generate_attachment_metadata() in my post but I do not know how to reach this cause it is located in the admin files. I'm trying ...
wordpress.org - WordPress › Support » BUG: wp_generate_attachment_metadata is ...
in /wp-admin/includes/image.php the function wp_generate_attachment_metadata is calling image_make_intermediate_size for each resize. This function ...
wordpress.org - wp_generate_attachment_metadata Wordpress hook details ...
WordPress version history for wp_generate_attachment_metadata. This database has information for all major versions from WP 1.2.1 through 3.3.
adambrown.info
Kullanýcý Tartýþmalarý [ wordpress.org ]
- vasilescu_anton on "wp_update_attachment_metadata not creating the other image sizes"
- thereformation on "wp_update_attachment_metadata not creating the other image sizes"
- vasilescu_anton on "wp_update_attachment_metadata not creating the other image sizes"
- vasilescu_anton on "wp_update_attachment_metadata not creating the other image sizes"
- Michael Fields on "How to manually generate thumbnails?"
- alkafy on "How to manually generate thumbnails?"
- alkafy on "How to manually generate thumbnails?"
- alkafy on "How to manually generate thumbnails?"
- Michael Fields on "How to manually generate thumbnails?"
- alkafy on "How to manually generate thumbnails?"