Wordpress:使用固定值裁剪图像并将其保存在媒体库中 [英] Wordpress: Crop Image with fixed value and save it in media library
本文介绍了Wordpress:使用固定值裁剪图像并将其保存在媒体库中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个网站,可以定期从选定的网站中获取快照.每个图像都以不同的方式裁剪,我已经保存了每个图像的裁剪数据.网站每天都会获取每个站点的更新快照,我希望将裁剪应用于新图像.我发现我可以裁剪调用图像编辑器实例
I have a site that periodically get snapshot from a selection of website. Each image has been cropped in a different way and I've saved the crop data for each. Every day the website gets the updated snapshot for each site and I want the crop to be apply to the new image. I found I can crop calling an image editor instance
$img = wp_get_image_editor( ABSPATH.'wp-content/uploads/temp/site_img.jpg' );
if ( ! is_wp_error( $img ) ) {
$img->crop( 130, 110, 107, 145, NULL, NULL, false );
}
我应该如何使用裁剪并将裁剪后的图像保存到媒体库中?
How should I use crop and save the cropped image to the media library?
解决方案
$image->save( 'new_image.jpg' );
现在可以了!!
推荐答案
很简单:
$image->save( 'new_image.jpg' );
这篇关于Wordpress:使用固定值裁剪图像并将其保存在媒体库中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文