image_edit_apply_changes [ WordPress Function ]
image_edit_apply_changes ( $img, $changes )
| Defined at: |
|
Benzer Fonksiyonlar: get_editable_roles, _load_image_to_edit_path, image_add_caption, add_media_page, _prime_post_caches
No description yet.
Source
<?php
function image_edit_apply_changes($img, $changes) {
if ( !is_array($changes) )
return $img;
// expand change operations
foreach ( $changes as $key => $obj ) {
if ( isset($obj->r) ) {
$obj->type = 'rotate';
$obj->angle = $obj->r;
unset($obj->r);
} elseif ( isset($obj->f) ) {
$obj->type = 'flip';
$obj->axis = $obj->f;
unset($obj->f);
} elseif ( isset($obj->c) ) {
$obj->type = 'crop';
$obj->sel = $obj->c;
unset($obj->c);
}
$changes[$key] = $obj;
}
// combine operations
if ( count($changes) > 1 ) {
$filtered = array($changes[0]);
for ( $i = 0, $j = 1; $j < count($changes); $j++ ) {
$combined = false;
if ( $filtered[$i]->type == $changes[$j]->type ) {
switch ( $filtered[$i]->type ) {
case 'rotate':
$filtered[$i]->angle += $changes[$j]->angle;
$combined = true;
break;
case 'flip':
$filtered[$i]->axis ^= $changes[$j]->axis;
$combined = true;
break;
}
}
if ( !$combined )
$filtered[++$i] = $changes[$j];
}
$changes = $filtered;
unset($filtered);
}
// image resource before applying the changes
$img = apply_filters('image_edit_before_change', $img, $changes);
foreach ( $changes as $operation ) {
switch ( $operation->type ) {
case 'rotate':
if ( $operation->angle != 0 )
$img = _rotate_image_resource($img, $operation->angle);
break;
case 'flip':
if ( $operation->axis != 0 )
$img = _flip_image_resource($img, ($operation->axis & 1) != 0, ($operation->axis & 2) != 0);
break;
case 'crop':
$sel = $operation->sel;
$scale = 1 / _image_get_preview_ratio( imagesx($img), imagesy($img) ); // discard preview scaling
$img = _crop_image_resource($img, $sel->x * $scale, $sel->y * $scale, $sel->w * $scale, $sel->h * $scale);
break;
}
}
return $img;
}
?>
Examples [ wp-snippets.com ]
Google Arama Sonuçlarý
- Docs for page image-edit.php
WordPress Image Editor. Functions. Description | Functions. image_edit_apply_changes (line 281). void image_edit_apply_changes ( $img, $changes). $img; $ ...
phpdoc.wordpress.org - PHPXRef 0.7 : WordPress : /wp-admin/includes/image-edit.php source
... $img, 0, 0, $x, $y, $w, $h) ) { 274 imagedestroy($img); 275 $img = $dst; 276 } 277 } 278 return $img; 279 } 280 281 function image_edit_apply_changes($img, ...
phpxref.ftwr.co.uk - stream_preview_image (WordPress Function) - WPSeek.com
$img = image_edit_apply_changes($img, $changes); // scale the image $w = imagesx($img); $h = imagesy($img); $ratio = _image_get_preview_ratio($w, $h); ...
wpseek.com - wp_save_image | A HitchHackers guide through WordPress
Feb 12, 2011... if ( $changes ) $img = image_edit_apply_changes($img, $changes); } else { $ return->error = esc_js( __('Nothing to save, the image has not ...
hitchhackerguide.com