一、配置wp-config.php文件中的一些参数
/** WordPress 数据库的名称 */ define('DB_NAME', SAE_MYSQL_DB); /** MySQL 数据库用户名 */ define('DB_USER', SAE_MYSQL_USER); /** MySQL 数据库密码 */ define('DB_PASSWORD', SAE_MYSQL_PASS); /** MySQL 主机 */ define('DB_HOST', SAE_MYSQL_HOST_M.':'.SAE_MYSQL_PORT);
二、修改文件调用和查看权限,wp-admin/includes/file.php文件
注释掉如下代码:
// Set correct file permissions $stat = stat( dirname( $new_file )); $perms = $stat['mode'] & 0000666; @ chmod( $new_file, $perms );
三、上传文件到Storage,wp-includes/functions.php文件
$bdir = $dir; $burl = $url;
上面添加如下代码:
//for SAE Start $dir = 'saestor://wordpress/uploads'; //wordpress是你的StorageDomain名字 $url = 'https://' . $_SERVER['HTTP_APPNAME'] . '-wordpress.stor.sinaapp.com/uploads'; //for SAE End
四、插入图片后不跳出错误,并能显示缩略图,wp-includes/media.php文件
(1)
$destfilename = "{$dir}/{$name}-{$suffix}.{$ext}";
下面添加一句:
$tmp = tempnam(SAE_TMP_PATH, 'WPIMG'); //为了SAE,增加这一句
(2)注释掉以下代码:
// Set correct file permissions $stat = stat( dirname( $destfilename )); $perms = $stat['mode'] & 0000666; //same permissions as parent folder, strip off the executable bits @ chmod( $destfilename, $perms );
(3)注释掉如下代码:
if ( IMAGETYPE_GIF == $orig_type ) { if ( !imagegif( $newimage, $destfilename ) ) return new WP_Error('resize_path_invalid', __( 'Resize path invalid' )); } elseif ( IMAGETYPE_PNG == $orig_type ) { if ( !imagepng( $newimage, $destfilename ) ) return new WP_Error('resize_path_invalid', __( 'Resize path invalid' )); } else { // all other formats are converted to jpg $destfilename = "{$dir}/{$name}-{$suffix}.jpg"; if ( !imagejpeg( $newimage, $destfilename, apply_filters( 'jpeg_quality', $jpeg_quality, 'image_resize' ) ) ) return new WP_Error('resize_path_invalid', __( 'Resize path invalid' )); }
替换为:
//为了SAE if ( IMAGETYPE_GIF == $orig_type ) { if ( !imagegif( $newimage, $tmp ) || !copy($tmp, $destfilename) ) return new WP_Error('resize_path_invalid', __( 'Resize path invalid' )); } elseif ( IMAGETYPE_PNG == $orig_type ) { if ( !imagepng( $newimage, $tmp ) || !copy($tmp, $destfilename) ) return new WP_Error('resize_path_invalid', __( 'Resize path invalid' )); } else { // all other formats are converted to jpg $destfilename = "{$dir}/{$name}-{$suffix}.jpg"; if ( !imagejpeg( $newimage, $tmp, apply_filters( 'jpeg_quality', $jpeg_quality, 'image_resize' ) ) || !copy($tmp, $destfilename) ) return new WP_Error('resize_path_invalid', __( 'Resize path invalid' )); }
(4)
$dst_file = preg_replace( '/\\.[^\\.]+$/', '.jpg', $dst_file );
下面添加如下代码:
$tmpfile = tempnam(SAE_TMP_PATH, 'WPIMG'); //FOR SAE if ( imagejpeg( $dst, $tmpfile, apply_filters( 'jpeg_quality', 90, 'wp_crop_image' ) ) && copy($tmpfile, $dst_file) ) return $dst_file; else return false;
原文地址: