本文整理汇总了PHP中wp_save_image函数的典型用法代码示例。如果您正苦于以下问题:PHP wp_save_image函数的具体用法?PHP wp_save_image怎么用?PHP wp_save_image使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wp_save_image函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: testImageEditOverwriteConstant
/**
* @ticket 32171
*/
public function testImageEditOverwriteConstant()
{
define('IMAGE_EDIT_OVERWRITE', true);
include_once ABSPATH . 'wp-admin/includes/image-edit.php';
$filename = DIR_TESTDATA . '/images/canola.jpg';
$contents = file_get_contents($filename);
$upload = wp_upload_bits(basename($filename), null, $contents);
$id = $this->_make_attachment($upload);
$_REQUEST['action'] = 'image-editor';
$_REQUEST['context'] = 'edit-attachment';
$_REQUEST['postid'] = $id;
$_REQUEST['target'] = 'all';
$_REQUEST['do'] = 'save';
$_REQUEST['history'] = '[{"c":{"x":5,"y":8,"w":289,"h":322}}]';
$ret = wp_save_image($id);
$media_meta = wp_get_attachment_metadata($id);
$sizes1 = $media_meta['sizes'];
$_REQUEST['history'] = '[{"c":{"x":5,"y":8,"w":189,"h":322}}]';
$ret = wp_save_image($id);
$media_meta = wp_get_attachment_metadata($id);
$sizes2 = $media_meta['sizes'];
$file_path = dirname(get_attached_file($id));
foreach ($sizes1 as $key => $size) {
if ($sizes2[$key]['file'] !== $size['file']) {
$files_that_shouldnt_exist[] = $file_path . '/' . $size['file'];
}
}
foreach ($files_that_shouldnt_exist as $file) {
$this->assertFileNotExists($file, 'IMAGE_EDIT_OVERWRITE is leaving garbage image files behind.');
}
}
开发者ID:aaemnnosttv,项目名称:develop.git.wordpress.org,代码行数:34,代码来源:MediaEdit.php
示例2: testCropImageThumbnail
/**
* @ticket 22985
*/
public function testCropImageThumbnail()
{
include_once ABSPATH . 'wp-admin/includes/image-edit.php';
$filename = DIR_TESTDATA . '/images/canola.jpg';
$contents = file_get_contents($filename);
$upload = wp_upload_bits(basename($filename), null, $contents);
$id = $this->_make_attachment($upload);
$_REQUEST['action'] = 'image-editor';
$_REQUEST['context'] = 'edit-attachment';
$_REQUEST['postid'] = $id;
$_REQUEST['target'] = 'thumbnail';
$_REQUEST['do'] = 'save';
$_REQUEST['history'] = '[{"c":{"x":5,"y":8,"w":289,"h":322}}]';
$media_meta = wp_get_attachment_metadata($id);
$this->assertArrayHasKey('sizes', $media_meta, 'attachment should have size data');
$this->assertArrayHasKey('medium', $media_meta['sizes'], 'attachment should have data for medium size');
$ret = wp_save_image($id);
$media_meta = wp_get_attachment_metadata($id);
$this->assertArrayHasKey('sizes', $media_meta, 'cropped attachment should have size data');
$this->assertArrayHasKey('medium', $media_meta['sizes'], 'cropped attachment should have data for medium size');
}
开发者ID:boonebgorges,项目名称:develop.wordpress,代码行数:24,代码来源:MediaEdit.php
示例3: wp_ajax_image_editor
/**
* Ajax handler for image editing.
*
* @since 3.1.0
*/
function wp_ajax_image_editor()
{
$attachment_id = intval($_POST['postid']);
if (empty($attachment_id) || !current_user_can('edit_post', $attachment_id)) {
wp_die(-1);
}
check_ajax_referer("image_editor-{$attachment_id}");
include_once ABSPATH . 'wp-admin/includes/image-edit.php';
$msg = false;
switch ($_POST['do']) {
case 'save':
$msg = wp_save_image($attachment_id);
$msg = wp_json_encode($msg);
wp_die($msg);
break;
case 'scale':
$msg = wp_save_image($attachment_id);
break;
case 'restore':
$msg = wp_restore_image($attachment_id);
break;
}
wp_image_editor($attachment_id, $msg);
wp_die();
}
开发者ID:hughnet,项目名称:WordPress,代码行数:30,代码来源:ajax-actions.php
示例4: intval
case 'image-editor':
$attachment_id = intval($_POST['postid']);
if (empty($attachment_id) || !current_user_can('edit_post', $attachment_id)) {
die('-1');
}
check_ajax_referer("image_editor-{$attachment_id}");
include_once ABSPATH . 'wp-admin/includes/image-edit.php';
$msg = false;
switch ($_POST['do']) {
case 'save':
$msg = wp_save_image($attachment_id);
$msg = json_encode($msg);
die($msg);
break;
case 'scale':
$msg = wp_save_image($attachment_id);
break;
case 'restore':
$msg = wp_restore_image($attachment_id);
break;
}
wp_image_editor($attachment_id, $msg);
die;
break;
case 'set-post-thumbnail':
$post_id = intval($_POST['post_id']);
if (!current_user_can('edit_post', $post_id)) {
die('-1');
}
$thumbnail_id = intval($_POST['thumbnail_id']);
if ($thumbnail_id == '-1') {
开发者ID:nagyist,项目名称:laura-wordpress,代码行数:31,代码来源:admin-ajax.php
示例5: call_user_func_array
die;
}
if ($form = $wp_registered_widget_controls[$widget_id]) {
call_user_func_array($form['callback'], $form['params']);
}
die;
break;
case 'image-edit-save':
// $post_id is the attachment ID
$post_id = intval($_POST['postid']);
if (empty($post_id) || !current_user_can('edit_post', $post_id)) {
die('-1');
}
check_ajax_referer("image_editor-{$post_id}");
include_once ABSPATH . 'wp-admin/includes/image-edit.php';
$msg = wp_save_image($post_id);
die($msg);
break;
case 'open-image-editor':
$post_id = intval($_POST['postid']);
if (empty($post_id) || !current_user_can('edit_post', $post_id)) {
die('-1');
}
check_ajax_referer("image_editor-{$post_id}");
include_once ABSPATH . 'wp-admin/includes/image-edit.php';
wp_image_editor($post_id);
die;
break;
default:
do_action('wp_ajax_' . $_POST['action']);
die('0');
开发者ID:bluedanbob,项目名称:wordpress,代码行数:31,代码来源:admin-ajax.php
注:本文中的wp_save_image函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论