Switch language

wpseek.com
A WordPress-centric search engine for devs and theme authors




load_image_to_edit [ WordPress Function ]

load_image_to_edit ( $attachment_id, $mime_type, $size = 'full' )
Parameters:
  • (string) $attachment_id Attachment ID.
  • (string) $mime_type Image mime type.
  • (string) $size Optional. Image size, defaults to 'full'.
Returns:
  • (resource|false) The resulting image resource on success, false on failure.
Defined at:



Load an image resource for editing.

Source


<?php
function load_image_to_edit$attachment_id$mime_type$size 'full' ) {
    
$filepath _load_image_to_edit_path$attachment_id$size );
    if ( empty( 
$filepath ) )
        return 
false;

    switch ( 
$mime_type ) {
        case 
'image/jpeg':
            
$image imagecreatefromjpeg($filepath);
            break;
        case 
'image/png':
            
$image imagecreatefrompng($filepath);
            break;
        case 
'image/gif':
            
$image imagecreatefromgif($filepath);
            break;
        default:
            
$image false;
            break;
    }
    if ( 
is_resource($image) ) {
        
$image apply_filters('load_image_to_edit'$image$attachment_id$size);
        if ( 
function_exists('imagealphablending') && function_exists('imagesavealpha') ) {
            
imagealphablending($imagefalse);
            
imagesavealpha($imagetrue);
        }
    }
    return 
$image;
}
?>

Examples [ wp-snippets.com ]

Top Google zoekresultaten

Meer ...

Gebruikersdiscussies [ wordpress.org ]

0 User Note(s)

Nog geen één. Wees de eerste!

Nieuw toevoegen ...



HTML5 Powered with CSS3 / Styling, Performance & Integration, and Semantics