Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
image_edit_apply_changes example
wp_raise_memory_limit
(
'admin'
)
;
$img
=
wp_get_image_editor
(
_load_image_to_edit_path
(
$post_id
)
)
;
if
(
is_wp_error
(
$img
)
)
{
return
false;
}
$changes
= !
empty
(
$_REQUEST
[
'history'
]
)
?
json_decode
(
wp_unslash
(
$_REQUEST
[
'history'
]
)
)
: null;
if
(
$changes
)
{
$img
=
image_edit_apply_changes
(
$img
,
$changes
)
;
}
// Scale the image.
$size
=
$img
->
get_size
(
)
;
$w
=
$size
[
'width'
]
;
$h
=
$size
[
'height'
]
;
$ratio
=
_image_get_preview_ratio
(
$w
,
$h
)
;
$w2
=
max
(
1,
$w
*
$ratio
)
;
$h2
=
max
(
1,
$h
*
$ratio
)
;