编辑图像时是否会触发挂钩(裁剪/重新调整大小)?我需要向管理员用户发送一封电子邮件通知,告知何时将编辑图像(裁剪/重新调整大小)。我还需要获取媒体/附件id,这些id必须通过电子邮件发送。
我需要你的建议。
编辑图像时是否会触发挂钩(裁剪/重新调整大小)?我需要向管理员用户发送一封电子邮件通知,告知何时将编辑图像(裁剪/重新调整大小)。我还需要获取媒体/附件id,这些id必须通过电子邮件发送。
我需要你的建议。
wp_save_image_editor_file
过滤器在之后激发。
add_filter( \'wp_save_image_editor_file\', \'custom_wp_save_image_editor_file\', 10, 5 );
function custom_wp_save_image_editor_file( $saved, $filename, $image, $mime_type, $post_id ){
//Your logic here
return $saved;
}
你可以试试image_editor_save_pre
过滤器:
add_filter( \'image_editor_save_pre\', \'custom_image_editor_save_pre\', 10 , 2 );
function custom_image_editor_save_pre( $image, $post_id){
// your stuff here
return $image;
}
裁剪/旋转图像并按下保存按钮时,似乎会调用此过滤器(这是一个预过滤器)这个$image
是类型的对象WP_Image_Editor_GD
下面是一个示例,说明它在过滤器中的外观:
WP_Image_Editor_GD Object
(
[image:protected] => Resource id #172
[file:protected] => /absolute/path/to/wordpress/install/wp-content/uploads/2013/07/car.jpg
[size:protected] => Array
(
[width] => 220
[height] => 330
)
[mime_type:protected] => image/jpeg
[default_mime_type:protected] => image/jpeg
[quality:protected] => 90
)
以及$post_id
是附件id。也许还有其他更好的钩子可以找,但我在
/wp-admin/includes/image-edit.php
在此功能中:/**
* Saves Image to File
*
* @param string $filename
* @param WP_Image_Editor $image
* @param string $mime_type
* @param int $post_id
* @return boolean
*/
function wp_save_image_file( $filename, $image, $mime_type, $post_id ) {
if ( $image instanceof WP_Image_Editor ) {
$image = apply_filters(\'image_editor_save_pre\', $image, $post_id);
$saved = apply_filters(\'wp_save_image_editor_file\', null, $filename, $image, $mime_type, $post_id);
Possible Duplicate:Resizing all images 我有一个我建立的新闻门户,客户想要不同大小的特色图片。我已经准备好了我想要的第一个尺寸,他们已经发布了大约200多篇帖子,都准备好了这个尺寸。现在,如果我改变大小,它只会在新帖子上改变/或重新上传当前的特色图片(手工操作太多了)。我的问题是,有没有办法调整上传图像的大小?