diff --git a/README.md b/README.md index 101a152472364926742764c04bce93e0957b9bc6..1574ee7fd7f92cdd66ae3dddefc33b5e4184d077 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ | ---------- | ------------------------------------------------------------ | | 中文名称 | 腾讯云验证码(COS)插件 | | 英文名称 | tencentcloud-cos | -| 最新版本 | v1.0.0 (2020.10.29) | +| 最新版本 | v1.0.1 (2021.01.12) | | 适用平台 | [Joomla](https://joomla.org/) | | 适用产品 | [腾讯云对象存储(COS)](https://cloud.tencent.com/product/cos) | | GitHub项目 | [tencentcloud-joomla-plugin-cos](https://github.com/Tencent-Cloud-Plugins/tencentcloud-joomla-plugin-cos) | @@ -27,7 +27,7 @@ - 开启插件后在后台的“内容管理“->“后台多媒体文件” 中上传的文件进行远程存储 - 开启插件后在后台的“内容管理“->“后台多媒体文件” 中删除文件同时会删除远程文件 - 创建博客并在博客中插入图片,图片会上传到远程存储中,在浏览博客的时候博客中的图片是从远程存储中加载的 - +- 数据万象功能,给网站中的图片添加水印 ## 3.安装指引 ### 3.1.部署方式一:通过GitHub部署安装 @@ -54,6 +54,7 @@

![](images/cos3.png) > 在【扩展管理】->【插件管理】中,选择腾讯云对象存储插件,配置插件需要的相关信息。 +>自定义水印编写规则参考 [数据万象官网](https://cloud.tencent.com/document/product/460) 的API文档。

![](images/cos4.png) @@ -66,6 +67,7 @@ - **所属地域**:在腾讯云服务器所在地域。详情参考[腾讯云文档](https://cloud.tencent.com/document/product/457/44232) - **空间名称**:COS服务中存储桶的名称。详情参考[腾讯云文档](https://cloud.tencent.com/document/product/436/41153) - **访问域名**:存储桶的访问域名。详情参考[腾讯云文档](https://cloud.tencent.com/document/product/436/6224) +- **数据万象**:开启数据万象对图片进行编辑,压缩、转换格式、水印添加等操作。详情参考[腾讯云文档](https://cloud.tencent.com/document/product/460/36540) ## 5.FAQ - **问题1**:开启腾讯云对象存储后,之前图片无法正常显示? @@ -83,12 +85,14 @@ ## 6.GitHub版本迭代记录 -### 6.1 tencentcloud-joomla-plugin-cos v1.0.0 +### 2021-01-12 tencentcloud-joomla-plugin-cos v1.0.1 +- 数据万象功能,给网站中的图片添加水印 + +### 2020-10-29 tencentcloud-joomla-plugin-cos v1.0.0 - 开启插件后在后台的“内容管理“->“后台多媒体文件” 中上传的文件进行远程存储 - 开启插件后在后台的“内容管理“->“后台多媒体文件” 中删除文件同时会删除远程文件 - 创建博客并在博客中插入图片,图片会上传到远程存储中,在浏览博客的时候博客中的图片是从远程存储中加载的 - --- 本项目由腾讯云中小企业产品中心建设和维护,了解与该插件使用相关的更多信息,请访问[春雨文档中心](https://openapp.qq.com/docs/Joomla/cos.html) diff --git a/images/cos3.png b/images/cos3.png index f00e414f214dccff9d558d5766d136d36cef9366..312c0758c3c641354ea700b1980deabe7401128f 100644 Binary files a/images/cos3.png and b/images/cos3.png differ diff --git a/tencentcloud_cos/TencentcloudCosAction.php b/tencentcloud_cos/TencentcloudCosAction.php index d9de1465cc1e1178fd07186169d1992badb7e1e4..19c6f2909c8e4286bc39da559cb8465f0dd6a181 100644 --- a/tencentcloud_cos/TencentcloudCosAction.php +++ b/tencentcloud_cos/TencentcloudCosAction.php @@ -22,6 +22,8 @@ require_once 'vendor/autoload.php'; class TencentcloudCosAction { + const DEFAULT_CI_RULE = 'watermark/2/text/6IW-6K6v5LqRwrfkuIfosaHkvJjlm74/fill/IzNEM0QzRA/fontsize/20/dissolve/50/gravity/northeast/dx/20/dy/20/batch/1/degree/45'; + /** * db * @var JDatabaseDriver|null @@ -55,6 +57,7 @@ class TencentcloudCosAction private $secret_key; private $region; private $bucket; + private $ci_rule; /** @@ -78,9 +81,24 @@ class TencentcloudCosAction $this->secret_key = isset($cos_options['secret_key']) ? $cos_options['secret_key'] : ''; $this->region = isset($cos_options['region']) ? $cos_options['region'] : ''; $this->bucket = isset($cos_options['bucket']) ? $cos_options['bucket'] : ''; + if (isset($cos_options['cloud_infinite']) && $cos_options['cloud_infinite'] === 1) { + if (isset($cos_options['ci_rule']) && $cos_options['ci_rule'] !== '') { + $this->ci_rule = $cos_options['ci_rule']; + } else { + $this->ci_rule = self::DEFAULT_CI_RULE; + } + } return true; } + /** + * 获取默认的数据万象规则 + */ + public function getCiRule() + { + return $this->ci_rule; + } + /** * 获取腾讯云对象存储插件的用户密钥 * @return array|bool 用户密钥 diff --git a/tencentcloud_cos/en-GB.plg_content_tencentcloud_cos.ini b/tencentcloud_cos/en-GB.plg_content_tencentcloud_cos.ini index f824a76bd373052dfca60b6e46badfe0ab1cd760..70b59cec6e089398c73de559dde6039d4965c1f2 100644 --- a/tencentcloud_cos/en-GB.plg_content_tencentcloud_cos.ini +++ b/tencentcloud_cos/en-GB.plg_content_tencentcloud_cos.ini @@ -35,4 +35,8 @@ PLG_CONTENT_TENCENTCLOUD_COS_SILICONVALLY="Silicon Valley" PLG_CONTENT_TENCENTCLOUD_COS_ASHBURN="Virginia" PLG_CONTENT_TENCENTCLOUD_COS_TORONTO="Toronto" PLG_CONTENT_TENCENTCLOUD_COS_FRANKFURT="Frankfurt" -PLG_CONTENT_TENCENTCLOUD_COS_MOSCOW="Moscow" \ No newline at end of file +PLG_CONTENT_TENCENTCLOUD_COS_MOSCOW="Moscow" +PLG_CONTENT_TENCENTCLOUD_COS_CLOUD_INFINITE="Open Data Vientiane" +PLG_CONTENT_TENCENTCLOUD_COS_CLOUD_INFINITE_DESC="After opening, the default watermark is 腾讯云 万象优图" +PLG_CONTENT_TENCENTCLOUD_COS_CI_RULE="Custom watermark rules" +PLG_CONTENT_TENCENTCLOUD_COS_CI_RULE_DESC="Custom watermark rules" \ No newline at end of file diff --git a/tencentcloud_cos/en-GB.plg_content_tencentcloud_cos.sys.ini b/tencentcloud_cos/en-GB.plg_content_tencentcloud_cos.sys.ini index 5e543da63f3247be0179a5be0e06351b90f143a3..746b9f5c442cff60d41c8c778dcdf7584b9af1fe 100644 --- a/tencentcloud_cos/en-GB.plg_content_tencentcloud_cos.sys.ini +++ b/tencentcloud_cos/en-GB.plg_content_tencentcloud_cos.sys.ini @@ -35,4 +35,8 @@ PLG_CONTENT_TENCENTCLOUD_COS_SILICONVALLY="Silicon Valley" PLG_CONTENT_TENCENTCLOUD_COS_ASHBURN="Virginia" PLG_CONTENT_TENCENTCLOUD_COS_TORONTO="Toronto" PLG_CONTENT_TENCENTCLOUD_COS_FRANKFURT="Frankfurt" -PLG_CONTENT_TENCENTCLOUD_COS_MOSCOW="Moscow" \ No newline at end of file +PLG_CONTENT_TENCENTCLOUD_COS_MOSCOW="Moscow" +PLG_CONTENT_TENCENTCLOUD_COS_CLOUD_INFINITE="Open Data Vientiane" +PLG_CONTENT_TENCENTCLOUD_COS_CLOUD_INFINITE_DESC="After opening, the default watermark is 腾讯云 万象优图" +PLG_CONTENT_TENCENTCLOUD_COS_CI_RULE="Custom watermark rules" +PLG_CONTENT_TENCENTCLOUD_COS_CI_RULE_DESC="Custom watermark rules" \ No newline at end of file diff --git a/tencentcloud_cos/script.php b/tencentcloud_cos/script.php index c3f77752ff2cc38bee37a56cc6e912622ff71765..39a56d879e33cd5f46d29a0d9d3c2d5d3c1fb8c4 100644 --- a/tencentcloud_cos/script.php +++ b/tencentcloud_cos/script.php @@ -60,7 +60,10 @@ class PlgContentTencentcloud_cosInstallerScript //获取配置 $conf = $this->cos_object->getSiteInfo(); //如果没有腾讯配置,则认为是第一次安装,写入初始化配置 - if (!$conf) $this->cos_object->setSiteInfo(); + + if (!$conf) { + $this->cos_object->setSiteInfo(); + } $this->cos_object->report('activate'); return true; } catch (RuntimeException $e) { diff --git a/tencentcloud_cos/tencentcloud_cos.php b/tencentcloud_cos/tencentcloud_cos.php index 07950fb8ba5eb1331707ea43c607ee04b7a4174a..5720f57f61612cf6099ece7c7b87193e74275f39 100644 --- a/tencentcloud_cos/tencentcloud_cos.php +++ b/tencentcloud_cos/tencentcloud_cos.php @@ -127,9 +127,18 @@ class PlgContentTencentcloud_cos extends JPlugin preg_match_all('/]+href=([\'"])(?.+?)\1[^>]*>/i', $text, $hrefResult); preg_match_all('/]+src=([\'"])(?.+?)\1[^>]*>/i', $text, $srcResult); $result = array_merge($hrefResult['href'], $srcResult['src']); + if (empty($result)) { + return $text; + } + $ciUrl = (new TencentcloudCosAction())->getCiRule(); foreach ($result as $link) { - $text = str_replace($link, $cos_options['remote_url'] . "/" . ltrim($link, '/'), $text); + $replaceString = $cos_options['remote_url'] . "/" . ltrim($link, '/'); + if (isset($cos_options['cloud_infinite']) && $cos_options['cloud_infinite'] === 1) { + $replaceString .= "?" . $ciUrl; + } + + $text = str_replace($link, $replaceString, $text); } return $text; } diff --git a/tencentcloud_cos/tencentcloud_cos.xml b/tencentcloud_cos/tencentcloud_cos.xml index 3db5fd60a5531ba91c7b7f8f088d638ea83f92f1..11866ce03ad35959c864386ec22065dd08cbd484 100644 --- a/tencentcloud_cos/tencentcloud_cos.xml +++ b/tencentcloud_cos/tencentcloud_cos.xml @@ -104,6 +104,28 @@ size="100" class="input-xxlarge" /> + + + + + diff --git a/tencentcloud_cos/zh-CN.plg_content_tencentcloud_cos.ini b/tencentcloud_cos/zh-CN.plg_content_tencentcloud_cos.ini index 37a4dc7f6e2f3092081e7e7a5c5cc9e56a056135..776ef6f93f653e56d343bf2351863c143dc95b01 100644 --- a/tencentcloud_cos/zh-CN.plg_content_tencentcloud_cos.ini +++ b/tencentcloud_cos/zh-CN.plg_content_tencentcloud_cos.ini @@ -1,6 +1,8 @@ PLG_CONTENT_TENCENTCLOUD_COS="内容 - 腾讯云对象存储" PLG_CONTENT_TENCENTCLOUD_COS_XML_DESCRIPTION="腾讯云对象存储" -PLG_CONTENT_TENCENTCLOUD_COS_DESCRIPTION="腾讯云对象存储实现网站静态媒体资源与腾讯云COS的互通,有效降低本地存储负载,提升用户访问网站媒体资源的体验。
查看插件使用说明可访问文档中心 , +PLG_CONTENT_TENCENTCLOUD_COS_DESCRIPTION="腾讯云对象存储实现网站静态媒体资源与腾讯云COS的互通,有效降低本地存储负载,提升用户访问网站媒体资源的体验。 + 自定义水印编写规则参考数据万象API文档的基础图片处理, +
查看插件使用说明可访问文档中心 , 获取插件源码可访问GitHub , 有任何问题可反馈建议" PLG_CONTENT_TENCENTCLOUD_COS_SECRET_ID="SecretId" @@ -34,4 +36,8 @@ PLG_CONTENT_TENCENTCLOUD_COS_SILICONVALLY="硅谷" PLG_CONTENT_TENCENTCLOUD_COS_ASHBURN="弗吉尼亚" PLG_CONTENT_TENCENTCLOUD_COS_TORONTO="多伦多" PLG_CONTENT_TENCENTCLOUD_COS_FRANKFURT="法兰克福" -PLG_CONTENT_TENCENTCLOUD_COS_MOSCOW="莫斯科" \ No newline at end of file +PLG_CONTENT_TENCENTCLOUD_COS_MOSCOW="莫斯科" +PLG_CONTENT_TENCENTCLOUD_COS_CLOUD_INFINITE="开启数据万象" +PLG_CONTENT_TENCENTCLOUD_COS_CLOUD_INFINITE_DESC="开启后,默认水印为 腾讯云 万象优图" +PLG_CONTENT_TENCENTCLOUD_COS_CI_RULE="自定义水印规则" +PLG_CONTENT_TENCENTCLOUD_COS_CI_RULE_DESC="自定义水印规则" \ No newline at end of file diff --git a/tencentcloud_cos/zh-CN.plg_content_tencentcloud_cos.sys.ini b/tencentcloud_cos/zh-CN.plg_content_tencentcloud_cos.sys.ini index 96c3b7f24c8661a163adf954b15049f91a5c4a2b..776ef6f93f653e56d343bf2351863c143dc95b01 100644 --- a/tencentcloud_cos/zh-CN.plg_content_tencentcloud_cos.sys.ini +++ b/tencentcloud_cos/zh-CN.plg_content_tencentcloud_cos.sys.ini @@ -1,7 +1,8 @@ PLG_CONTENT_TENCENTCLOUD_COS="内容 - 腾讯云对象存储" PLG_CONTENT_TENCENTCLOUD_COS_XML_DESCRIPTION="腾讯云对象存储" -PLG_CONTENT_TENCENTCLOUD_COS_DESCRIPTION="腾讯云对象存储实现网站静态媒体资源与腾讯云COS的互通,有效降低本地存储负载,提升用户访问网站媒体资源的体验。
- 查看插件使用说明可访问文档中心 , +PLG_CONTENT_TENCENTCLOUD_COS_DESCRIPTION="腾讯云对象存储实现网站静态媒体资源与腾讯云COS的互通,有效降低本地存储负载,提升用户访问网站媒体资源的体验。 + 自定义水印编写规则参考数据万象API文档的基础图片处理, +
查看插件使用说明可访问文档中心 , 获取插件源码可访问GitHub , 有任何问题可反馈建议" PLG_CONTENT_TENCENTCLOUD_COS_SECRET_ID="SecretId" @@ -35,4 +36,8 @@ PLG_CONTENT_TENCENTCLOUD_COS_SILICONVALLY="硅谷" PLG_CONTENT_TENCENTCLOUD_COS_ASHBURN="弗吉尼亚" PLG_CONTENT_TENCENTCLOUD_COS_TORONTO="多伦多" PLG_CONTENT_TENCENTCLOUD_COS_FRANKFURT="法兰克福" -PLG_CONTENT_TENCENTCLOUD_COS_MOSCOW="莫斯科" \ No newline at end of file +PLG_CONTENT_TENCENTCLOUD_COS_MOSCOW="莫斯科" +PLG_CONTENT_TENCENTCLOUD_COS_CLOUD_INFINITE="开启数据万象" +PLG_CONTENT_TENCENTCLOUD_COS_CLOUD_INFINITE_DESC="开启后,默认水印为 腾讯云 万象优图" +PLG_CONTENT_TENCENTCLOUD_COS_CI_RULE="自定义水印规则" +PLG_CONTENT_TENCENTCLOUD_COS_CI_RULE_DESC="自定义水印规则" \ No newline at end of file