yiichou / aliyun-oss-support Goto Github PK
View Code? Open in Web Editor NEW基于阿里云OSS的WordPress远程附件支持插件
License: Other
基于阿里云OSS的WordPress远程附件支持插件
License: Other
域名:example.com
网站:www.example.com
OSS外网地址:somebucket.blabla.example.com
OSS绑定域名:oss.example.com
CDN加速域名:cdn.example.com -> somebucket.blabla.example.com
CNAME解析:oss.example.com -> cdn.example.com
此时本插件的的bucket域名不能改为CDN地址,否则无法访问,不修改的话,保存的图片不会被CDN加速
上传图片没传到OSS,以前的图片链接也没变化
如题,哈哈哈
如题,启用BuddyPress之后,不能修改头像以及背景图。可以的话,下个版本发布时可以修复一下吗?
现在是在wordpress上传的图片会同步到阿里云oss里面去,
如果我单独上传图片到阿里云oss里面,
在wordpress网站这边显示出单独在阿里云oss上传的图片。
这样对多个网站用同个附件挺有帮助的。
不知道阿里云oss是否支持这样做?
阿里云oss已经可以直通阿里云cdn了
比在阿里云cdn管理界面设置cdn简单,还省去了域名审核的步骤
官方文档也鼓励用户把CSS和js文件储存到oss,然后配合cdn加速,如下:https://help.aliyun.com/document_detail/31936.html?spm=5176.doc31885.6.639.kIEydD
有这个功能的话,七牛的优势将会消失殆尽.....
由于阿里云OSS 图片处理Api更新,导致插件失效.....
好像php7.2的某个函数不支持了?
wordpress编辑器上传的文章正文图片可正确按图片样式方式在前端调用,但是特色图像(post-thumbnail)的调用是这种形式的img-530x640.jpg
反馈者邮箱: [email protected]
上传图片显示HTTP错误,但是实际上已经上传成功,只有缩略图无法显示出来。
PHP版本:5.4
插件版本:3.0.2
2016-08-12看到这个插件是唯一更新了aliyun-oss-php-sdk的插件,然而并用不了 OnO。。请问一下markdown文件里说的回源是什么意思呢,localhost也能使用回源吗
在Wordpress中,如果直接上传,它会把文件保存在本月的目录下(如/2014/12/),但是如果在文章中上传,它会把文件保存在文章发布日的目录下(如/2011/08/),使用了这个插件之后,我发现在数据库和服务器本地硬盘中的地址都是文章发布日的,而OSS上的文件会新建在本月,于是会导致读不出来这个文件,不知道这算不算一个bug。
via: sjw(at)cnsjw.cn
正常媒体库上传可以及时更改链接,但使用Download Monitor快速上传的时候只会给出本应该上传到的链接,即upload/dlm_upload/xxxxx,而非直接给出OSS的链接。。。
希望能给这个比较多人用的插件做下优化QAQ
如何升级到3.1.5的版本?正在使用的是2.3.2的版本。 谢谢
Today JP region is opened. So I want to support JP region oss.
Can you support this?
如题
简洁帅气啊~~感谢!
阿里云 OSS 与 CDN 融合在一起使用,效果不错。
近期有木有对融合 CDN 提供支持的计划捏 TvT~
您好,
因为插件不支持中文图片,因此应用之后发现部分图片无法显示出来。
在应用插件之前,网站已经上传几百于张图片,多数图片为中文命名。按照迁移流程完成图片服务器的设置之后,有部分图片显示不出来。因此进行了几天的追踪,发现为oss-support.php文件中的205行
$filename = basename($data['file']);
php中的basename函数不支持中文所致。因此尝试进行了修复,替换为
$filename = preg_replace('/^.+[\\\\\\/]/', '', $data['file']);
//网上搜寻的用于修复basename不支持中文的修复方案
目前工作基本正常。
上传100M左右的Mp4视频格式的文件上传到100%以后会出现http错误
在使用EvernoteSync插件,把图文同步到OSS后,在wp下,图片都无法显示。
原因是,如果图片是a.jpg, 在同步后,oss上的名字是a-100x43.jpg, a-150x150.jpg, a-300x300.jpg,唯独没有a.jpg。
如果不使用OSS插件,同步后,图片可以正常显示,且在code和wp媒体的图片名是a.jpg
奇怪的是,如果使用OSS,新建文章插入图片,图片都是没有问题的,而且在OSS的名字是a.jpg。
不知道为什么使用EvernoteSync后,图片上传到OSS就被自动标记了分辨率,在阿里OSS各种设置,也没有效果。
求帮助
https://help.aliyun.com/document_detail/31837.html
ecs处于vpc环境时,访问oss稍微有一点小区别,能增加下对vpc环境的支持么
不使用「预设图片样式」没有问题,启用「预设样式」后,动图不会动了
这是 aliyun OSS 改版后的一个 bug,不知道 OSS 什么时候会修
使用ultimate member插件时,上传头像等操作都是失败的,大致调试了一下,发现是选择图片时,生成临时文件的URL还是wp-content/uploads ,上传时却又变成OSS的URL,导致上传图片失败,请问一下这个冲突怎么解决?
我使用阿里云的弹性WEB托管,不能启用插件,错误如下:
无法启用插件,因为它引起了一个致命错误(fatal error)。
ERROR: manifest length read was "389051" should be "7602176"
不知道是为什么
错误信息如下
Warning: filesize():
stat failed for /data/home/bxu2359040325/htdocs/wp-content/uploads/2016/10/[email protected] in phar:///data/home/bxu2359040325/htdocs/wp-content/plugins/aliyun-oss-support-master/aliyun-oss-php-sdk-2.0.7.phar/src/OSS/OssClient.php on line 1310
Fatal error: Uncaught exception 'OSS\Core\OssException' with message 'The size of fileUpload
cannot be determined in multiuploadFile().' in phar:///data/home/bxu2359040325/htdocs/wp-content/plugins/aliyun-oss-support-master/aliyun-oss-php-sdk-2.0.7.phar/src/OSS/OssClient.php:1317 Stack trace:
#0 /data/home/bxu2359040325/htdocs/wp-content/plugins/aliyun-oss-support-master/src/Upload.php(61): OSS\OssClient->multiuploadFile('bucket-3', 'wp-content/uplo...', '/data/home/bxu2...', Array)
#1 [internal function]: OSS\WP\Upload->uploadThumbToOss(Array)
#2 /data/home/bxu2359040325/htdocs/wp-includes/plugin.php(235): call_user_func_array(Array, Array)
#3 /data/home/bxu2359040325/htdocs/wp-includes/post.php(4891): apply_filters('wp_update_attac...', Array, 153)
#4 /data/home/bxu2359040325/htdocs/wp-admin/includes/media.php(375): wp_update_attachment_metadata(153, Array)
#5 /data/home/bxu2359040325/htdocs/wp-admin/async-upload.php(93): media_handle_upload('async-upload', 0)
#6 {main} thrown in phar:///data/home/bxu2359040325/htdocs/wp-content/plugins/aliyun-oss-support-master/aliyun-oss-php-sdk-2.0.7.phar/src/OSS/OssClient.php on line 1317
$config = array(
'id' => 'xx',
'key' => 'xx',
'bucket' => 'xx',
'endpoint' => 'oss.aliyuncs.com'
);
$cache = Alibaba::Storage($config);
青岛节点外网地址: oss-cn-qingdao.aliyuncs.com
青岛节点内网地址: oss-cn-qingdao-internal.aliyuncs.com
北京节点外网地址:oss-cn-beijing.aliyuncs.com
北京节点内网地址:oss-cn-beijing-internal.aliyuncs.com
杭州节点外网地址: oss-cn-hangzhou.aliyuncs.com
杭州节点内网地址: oss-cn-hangzhou-internal.aliyuncs.com
香港节点外网地址: oss-cn-hongkong.aliyuncs.com
香港节点内网地址: oss-cn-hongkong-internal.aliyuncs.com
深圳节点外网地址: oss-cn-shenzhen.aliyuncs.com
深圳节点内网地址: oss-cn-shenzhen-internal.aliyuncs.com
美国硅谷节点外网地址: oss-us-west-1.aliyuncs.com
美国硅谷节点内网地址: oss-us-west-1-internal.aliyuncs.com
原地址oss.aliyuncs.com 默认指向杭州节点外网地址
原内网地址oss-internal.aliyuncs.com 默认指向杭州节点内网地址
参看链接:
http://docs.aliyun.com/#/ace/sdk/php&storage
http://docs.aliyun.com/#/oss/product-documentation/domain-region
有需要的拿去用。
require_once(ABSPATH . '/wp-content/plugins/aliyun-oss-support/src/Config.php');
require_once(ABSPATH . '/wp-content/plugins/aliyun-oss-support/src/UrlHelper.php');
use OSS\WP\Config;
use OSS\WP\UrlHelper;
class ImageUtility
{
/**
* 根据传入的相对路径,获取 OSS 路径
* @param $url
* @param $style
* @param $storePath OSS 基础路径 名称,不填则采用后台配置的路径
* @return string
*/
public static function get_ali_image_src_by_src($url, $style, $storePath = null)
{
$storePath = empty($storePath) ? Config::$storePath : $storePath;
$staticHost = Config::$staticHost;
$u = $staticHost . $storePath . $url;
return UrlHelper::aliImageStyle($u, $style);
}
/**
* 在传入的图片 url 追加上 oss style
* @param $url
* @param $style
* @return string
*/
public static function append_ali_image_src_style($url, $style)
{
if (is_array($url)) $url = @$url[0];
$index = strpos($url, "?x-oss-process=");
$u = ($index == -1) ? $url : substr($url, 0, $index);
return UrlHelper::aliImageStyle($u, $style);
}
}
用法:
放到 php 里面
require_once 进来
use ImageUtility;
调用就可以了
ImageUtility::get_ali_image_src_by_src("folder1/image1.jpg","full");
invalid Issues
On Media/Library page, following errors displayed under each image file if he file display mode is set to list.
If the display mode is set to grid, no such errors.
Env:
Warning: Missing argument 3 for modefiy_img_srcset_url() in
{My Site Root Url}/wp-content/plugins/aliyun-oss-support-master/oss-support.php on line 249
Warning: Missing argument 4 for modefiy_img_srcset_url() in
/{My Site Root Url}/wp-content/plugins/aliyun-oss-support-master/oss-support.php on line 249
Warning: Missing argument 5 for modefiy_img_srcset_url() in
{My Site Root Url}/wp-content/plugins/aliyun-oss-support-master/oss-support.php on line 249
目前发现只能上传图片哦。谢谢
上传主题 和 插件 时,也会传到 oss,然后报错
srcset
的图片显示我当前应用的是WordPress 4.4.2版本,文章中插入的图片,如果编辑过大小,那么WordPress会使用srcset
项目来根据缩放大小自动的显示图片。示例如下:
<img class="alignnone wp-image-463" src="http://img.example.com/wp/2016/03/example.jpg" alt="example" width="201"
height="201"
srcset="http://oss.example.com/wp/2016/03/example-150x150.jpg 150w,
http://oss.example.com/wp/2016/03/example-300x300.jpg 300w,
http://oss.example.com/wp/2016/03/example-768x768.jpg 768w,
http://oss.example.com/wp/2016/03/example-1024x1024.jpg 1024w,
http://oss.example.com/wp/2016/03/example-210x210.jpg 210w,
http://oss.example.com/wp/2016/03/example.jpg 1280w"
sizes="(max-width: 201px) 100vw, 201px">
此代码存在两个问题
oss.example.com
是附件上传地址,无法使用OSS的图片服务。example.jpg@!thumbnail
等。经过研究代码后发现,此项功能并没有应用wp_get_attachment_url
这项功能,而是由函数内部通过wp_calculate_image_srcset_meta
和_wp_upload_dir_baseurl
获取链接后自行拼接。因此,为了修复这个问题,我同时修改了插件和WordPress源代码来修复这一问题。(由于本人对WordPress并不熟悉,因此修复方案并非最佳解决方案,如果有更好方案请互相交流。)
修改PATH/wp-content/plugins/aliyun-oss-support-master/oss-support.php
文件
// wp-content/plugins/aliyun-oss-support-master/oss-support.php
// 第194行起
if(!$oss_options['img_url'] == "")
add_action('wp_delete_file', 'delete_thumb_img', 99);
改为
if(!$oss_options['img_url'] == ""){
add_filter('wp_get_attachment_metadata', 'modefiy_img_meta', 990);
add_filter('wp_calculate_image_srcset_meta', 'modefiy_img_meta', 990); //增加此项处理
}
修改 PATH/wp-includes/media.php
文件
// wp-includes/media.php
// 第1048行起(4.4.2版本)
$image_baseurl = _wp_upload_dir_baseurl();
$image_baseurl = trailingslashit( $image_baseurl ) . $dirname;
改为
$image_baseurl = _wp_upload_dir_baseurl();
//插入如下部分,借用了插件中替换url的部分代码
$oss_options = get_option('oss_options', TRUE);
if(!$oss_options['img_url'] == ""){
$image_baseurl = rtrim($oss_options['img_url'], '/');
if(rtrim($oss_options['path'], '/') != ""){
$image_baseurl = $image_baseurl .'/'. rtrim($oss_options['path'], '/');
}
}
$image_baseurl = trailingslashit( $image_baseurl ) . $dirname;
运行效果演示(可正常的从oss中获取图片并显示出来)
<img class="alignnone wp-image-463" src="http://img.example.com/wp/2016/03/example.jpg" alt="example" width="201"
height="201"
srcset="http://img.example.com/wp/2016/03/example.jpg@!thumbnail 150w,
http://img.example.com/wp/2016/03/example.jpg@!medium 300w,
http://img.example.com/wp/2016/03/example.jpg@!medium_large 768w,
http://img.example.com/wp/2016/03/example.jpg@!large 1024w,
http://img.example.com/wp/2016/03/example.jpg@!medium 210w,
http://img.example.com/wp/2016/03/example.jpg 1280w"
sizes="(max-width: 201px) 100vw, 201px">
可以看到,链接被替换成img.example.com
,图片名称也正确了。
另外,演示代码中的图片类型数量与原版插件支持的要多一些(如多了medium_large),如果有需要,请自行在oss-support.php
文件的modefiy_img_meta
函数中添加(请在阿里云OSS后台的图片处理功能中也一并添加,具体教程在插件安装说明中)。
安装好插件后,我进行了一次批量的wp-content/uploads
上传到OSS服务器的文件传输。
但是,已经上传好的文章中,还是保存着本地的文件链接,修改方法只需要运行一次SQL指令即可,指令如下:
update `wp_posts` set `post_content`=REPLACE(`post_content`,'http://example.com/wp-content/uploads/','http://img.example.com/wp/');
请注意,请先备份数据库,并将上诉SQL语句中的两个链接替换成您自己的地址
http://example.com/wp-content/uploads/
- 之前数据库中保存的链接
http://img.example.com/wp/
- 阿里云OSS的图片链接
如果wp安装了ARMember插件,启动aliyun-oss-support会报错
您好,插件无问题,可用,赞!
插件的图片服务只支持 6 种样式,能够支持WooCommerce的图片服务吗?(shop_thumbnail、shop_catalog、shop_single)
通过后台设置的6个样式,看来二维码显示不了啊
此问题在未勾选“不在本地保存原图”功能时出现
操作步骤:
将两张不同的jpg图片A,B,先后命名为同一个名字然后先后上传,然后点击后上传的图片
预期:
显示为图片A
实际:
显示为图片B
继续操作:
在出错的这张图B下点“编辑图片”
预期:
展示出错的原图B
实际:
展示正确的原图A
继续操作:
在这张正确的原图A上,截取全图保存
预期:
保存为正确的原图A
实际:
保存为正确的原图A,但文件名相同的文件B,被覆盖成了A,同时 ,删除A,B任意一张图,都会导致两张图都打不开
推断:
WordPress自带的上传,能自动判断文件是否重名,并重命名文件,但上传到oss后,文件名无法判断文件是否重名,所以出现了后图覆盖前图的情况,望作者能抽空看看
请教一下,怎么给存在OSS的原图加水印呢?我加了4个OSS样式(medium,large,post-thumbnail,thumbnail) ,后台媒体里看到缩略图都是有水印的,但原图没有水印,原图要怎么加水印呢?原图的样式叫什么呢?
Fatal error: Class 'OSS\WP\Config' not found in /home/wwwroot/domain.com/wp-content/plugins/aliyun-oss/aliyun-oss.php on line 33
自己命名的缩略图名称,插件无法传递给oss。
看了一下代码 UrlHelper.php
foreach(array('thumbnail', 'post-thumbnail', 'medium', 'medium_large', 'large', 'full') as $style ) {
这里只有WP默认的缩略图名称,
我自己在后面添加了主题注册和自己注册的名称后,才能正常使用。
请问这的确需要这么改动才能起作用吗?
还是我的设置问题吗?
今天发现了插件!
点赞诶!
但是遇到点问题就是开启插件之后 设置应该没错误
然后网站就一直loading
一直loading
换过不同的bucket
关闭之后 立马打开网站
不知道为什么
还希望大大能建个群 大家一起交流呀
3.0beta里面,aliyun-oss-wp.phar不利于修改,建议还是不要打包了,比如我现在就想修改一下图片服务的参数,默认的 20w_30h_1l_1c 不是太适合我
上传图片后多媒体里面的缩略图不显示OSS上也没有该图片
PHP版本:7.0
插件版本:3.1.4
看了下历史issues,似乎与 #23 bug有些相似
上传文件到服务器成功,但是oss里面没有。
看上去是sdk包太旧造成的。
与the7不兼容 开启插件 界面就变了 jhdcl.com
Parse error: syntax error, unexpected '
文件末尾增加?>后提示
Parse error: syntax error, unexpected '['
实在不会搞了 特来求助
文章插入图片,尺寸选在“完整尺寸”,文章在预览时图片的srcset里没有用@!origin标
<a href="https://osspath/images/2017/01/network-interfaces.png@!origin" target="_blank"><img class="aligncenter wp-image-295 size-full" src="https://osspath/images/2017/01/network-interfaces.png@!origin" alt="OpenWrt-Network-Interface-Overview" width="971" height="861" srcset="https://osspath/images/2017/01/network-interfaces.png 971w, https://osspath/images/2017/01/network-interfaces.png?x-oss-process=style/medium 300w, https://osspath/images/2017/01/network-interfaces.png?x-oss-process=style/medium_large 768w" sizes="(max-width: 971px) 100vw, 971px"></a>
编码问题
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.