├── codecov.yml
├── code-of-conduct.md
├── contributing.md
├── src
├── resources
│ └── views
│ │ └── plugins
│ │ └── page-tab-external-image-link
│ │ ├── external-image-link.blade.php
│ │ └── config.php
├── LaravelCmsPluginServiceProvider.php
├── database
│ └── migrations
│ │ └── 2019_10_02_112021_update_plugin_settings_table.php
└── Controllers
│ └── ExternalImageLinkController.php
├── .styleci.yml
├── .editorconfig
├── .php_cs
├── license.md
├── composer.json
└── README.md
/codecov.yml:
--------------------------------------------------------------------------------
1 | comment: false
--------------------------------------------------------------------------------
/code-of-conduct.md:
--------------------------------------------------------------------------------
1 | # Code of Conduct
2 |
3 | - Check the .php_cs
4 |
--------------------------------------------------------------------------------
/contributing.md:
--------------------------------------------------------------------------------
1 | # Contributing
2 |
3 | - Any open source product is only as good as the community behind it. You can participate by sharing code, ideas, or simply helping others. No matter what your skill level is, every contribution counts.
4 |
--------------------------------------------------------------------------------
/src/resources/views/plugins/page-tab-external-image-link/external-image-link.blade.php:
--------------------------------------------------------------------------------
1 | {{-- actually didn't need this, reserve it for the future --}}
2 | @include($helper->bladePath('includes.form-input','b'), ['name' =>
3 | "remote_image_save_to_local", 'type'=>'select', 'options'=>['0' => $helper->t('disable'), '1' =>
4 | $helper->t('enable')] ])
5 |
--------------------------------------------------------------------------------
/.styleci.yml:
--------------------------------------------------------------------------------
1 | preset: laravel
2 | risky: false
3 | enabled:
4 | - alpha_ordered_imports
5 | - align_double_arrow
6 | - align_equals
7 | disabled:
8 | - length_ordered_imports
9 | - unused_use
10 | - unalign_equals
11 | finder:
12 | exclude:
13 | - modules
14 | - node_modules
15 | - storage
16 | - vendor
17 | name: "*.php"
18 | not-name: "*.blade.php"
19 |
--------------------------------------------------------------------------------
/.editorconfig:
--------------------------------------------------------------------------------
1 | # For more information about the properties used in this file,
2 | # please see the EditorConfig documentation:
3 | # http://editorconfig.org
4 |
5 | [*]
6 | charset = utf-8
7 | end_of_line = lf
8 | indent_size = 4
9 | indent_style = space
10 | insert_final_newline = true
11 | trim_trailing_whitespace = true
12 |
13 | [*.{yml,js,json,css,scss,feature,eslintrc}]
14 | indent_size = 2
15 | indent_style = space
16 |
17 | [composer.json]
18 | indent_size = 4
--------------------------------------------------------------------------------
/src/resources/views/plugins/page-tab-external-image-link/config.php:
--------------------------------------------------------------------------------
1 | [
5 | 'version' => '0.2.1',
6 | 'github_full_name' => 'AlexStack/Laravel-CMS-Plugin-External-Image-Link',
7 | 'plugin_name' => 'External Images & Links',
8 | ],
9 | 'zh'=> [
10 | 'version' => '0.2.1',
11 | 'github_full_name' => 'AlexStack/Laravel-CMS-Plugin-External-Image-Link',
12 | 'plugin_name' => '下载远程图片和SEO外部连接',
13 | ],
14 | ];
15 |
--------------------------------------------------------------------------------
/src/LaravelCmsPluginServiceProvider.php:
--------------------------------------------------------------------------------
1 | publishes([__DIR__.'/resources/views/plugins' => base_path('resources/views/vendor/laravel-cms/plugins')], 'external-image-link-views');
16 | }
17 |
18 | /**
19 | * Register the application services.
20 | */
21 | public function register()
22 | {
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/.php_cs:
--------------------------------------------------------------------------------
1 | notPath('bootstrap/cache')
7 | ->notPath('storage')
8 | ->notPath('vendor')
9 | ->in(__DIR__)
10 | ->name('*.php')
11 | ->notName('*.blade.php')
12 | ->ignoreDotFiles(true)
13 | ->ignoreVCS(true)
14 | ;
15 |
16 | return PhpCsFixer\Config::create()
17 | ->setRules(array(
18 | '@Symfony' => true,
19 | 'binary_operator_spaces' => ['align_double_arrow' => true, 'align_equals' => true],
20 | 'array_syntax' => ['syntax' => 'short'],
21 | 'linebreak_after_opening_tag' => true,
22 | 'not_operator_with_successor_space' => true,
23 | 'ordered_imports' => true,
24 | 'phpdoc_order' => true,
25 | ))
26 | ->setFinder($finder)
27 | ;
28 |
--------------------------------------------------------------------------------
/license.md:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (C) 2019-2020 Alex Zeng
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6 |
7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8 |
9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
10 |
--------------------------------------------------------------------------------
/composer.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "alexstack/laravel-cms-plugin-external-image-link",
3 | "description": "Save all remote images in the page content editors to your server, replace the image URL from remote URL to your local URL. Add rel=nofollow & target=_blank to external links for better SEO and user experience.",
4 | "type": "amila-laravel-cms-plugin",
5 | "homepage": "https://github.com/AlexStack/Laravel-CMS-Plugin-External-Image-Link",
6 | "keywords": [
7 | "laravel",
8 | "amila laravel cms",
9 | "remote image",
10 | "local image",
11 | "nofollow",
12 | "noindex",
13 | "amila laravel cms plugin"
14 | ],
15 | "license": "MIT",
16 | "support": {
17 | "issues": "https://github.com/AlexStack/Laravel-CMS-Plugin-External-Image-Link/issues"
18 | },
19 | "authors": [{
20 | "name": "Alex",
21 | "homepage": "https://github.com/AlexStack/Laravel-CMS-Plugin-External-Image-Link"
22 | }],
23 | "require": {
24 | "php": ">=7.0.0",
25 | "alexstack/laravel-cms": "*"
26 | },
27 | "autoload": {
28 | "psr-4": {
29 | "Amila\\LaravelCms\\Plugins\\ExternalImageLink\\": "src/"
30 | }
31 | },
32 | "minimum-stability": "dev",
33 | "extra": {
34 | "laravel": {
35 | "providers": [
36 | "Amila\\LaravelCms\\Plugins\\ExternalImageLink\\LaravelCmsPluginServiceProvider"
37 | ]
38 | },
39 | "laravel-cms": {
40 | "plugin-param-name": "page-tab-external-image-link"
41 | }
42 | },
43 | "scripts": {
44 | "post-package-install": [
45 | "php artisan migrate --path=./vendor/alexstack/laravel-cms-plugin-external-image-link/src/database/migrations/",
46 | "php artisan vendor:publish --provider=Amila\\LaravelCms\\Plugins\\ExternalImageLink\\LaravelCmsPluginServiceProvider",
47 | "php artisan laravelcms --action=clear"
48 | ]
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/src/database/migrations/2019_10_02_112021_update_plugin_settings_table.php:
--------------------------------------------------------------------------------
1 | config = include base_path('config/laravel-cms.php');
14 | $this->table_name = $this->config['table_name']['settings'];
15 | }
16 |
17 | /**
18 | * Run the migrations.
19 | */
20 | public function up()
21 | {
22 | $setting_data = [
23 | 'category' => 'plugin',
24 | 'param_name' => 'page-tab-external-image-link',
25 | 'input_attribute' => '{"rows":15,"required":"required"}',
26 | 'enabled' => 1,
27 | 'sort_value' => 55,
28 | 'abstract' => 'Save external images to your server and add rel=nofollow to the external links. Tutorial',
29 | 'param_value' => '{
30 | "plugin_name" : "External Images & Links",
31 | "blade_file" : "external-image-link",
32 | "tab_name" : "",
33 | "php_class" : "Amila\\\\LaravelCms\\\\Plugins\\\\ExternalImageLink\\\\Controllers\\\\ExternalImageLinkController",
34 | "version": "0.2.0",
35 | "remote_image_to_local" : {
36 | "enable": true,
37 | "exclude":[".laravelcms.tech","localhost/",".test", ".local"],
38 | "local_image_size": "original",
39 | "replace_fields": ["main_content","sub_content","extra_content_1","extra_content_2","extra_content_3"]
40 | },
41 | "nofollow_external_links" : {
42 | "enable": true,
43 | "exclude":["localhost/",".test", ".laravelcms.tech"],
44 | "rel_text": "nofollow noopener external noindex",
45 | "target" : "_blank",
46 | "replace_fields": ["main_content","sub_content","extra_content_1","extra_content_2","extra_content_3"]
47 | }
48 | }',
49 | ];
50 | LaravelCmsSetting::UpdateOrCreate(
51 | ['category'=>'plugin', 'param_name' => 'page-tab-external-image-link'],
52 | $setting_data
53 | );
54 | }
55 |
56 | /**
57 | * Reverse the migrations.
58 | */
59 | public function down()
60 | {
61 | LaravelCmsSetting::where('param_name', 'page-tab-external-image-link')->where('category', 'plugin')->delete();
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Save external images to your server and add rel=nofollow to the external links
2 |
3 | - This is an Amila Laravel CMS Plugin
4 | - Save all remote images in the page contents editor to your server, replace the image URL from remote URL to your local URL. Add rel=nofollow & target=\_blank to external links for better SEO and user experience.
5 |
6 | ## Install it via the backend
7 |
8 | - Go to the CMS settings page -> Plugin -> search for remote image
9 | - Find alexstack/laravel-cms-plugin-external-image-link
10 | - Click the Install button
11 |
12 | ## What the plugin do for us?
13 |
14 | - Save the remote images in the content editors to your server (eg. Main Content, Sub Content, Extra Content ...). You will be able to find them on the File Manager page afterward.
15 | - Automatically convert the remote image URLs to the local relative URLs. eg.
16 |
17 | ```php
18 |
19 |
20 | will automatically convert to below for you:
21 |
22 |
23 | ```
24 |
25 | - Automatically add rel="nofollow" & target="\_blank" to external links for better SEO and user experience. eg.
26 |
27 | ```php
28 | Laravel CMS
29 |
30 | will automatically convert to below for you:
31 |
32 | Laravel CMS
33 |
34 | ```
35 |
36 | ## Install it via command line manually
37 |
38 | ```php
39 | composer require alexstack/laravel-cms-plugin-external-image-link
40 |
41 | php artisan migrate --path=./vendor/alexstack/laravel-cms-plugin-external-image-link/src/database/migrations
42 |
43 | php artisan vendor:publish --force --tag=external-image-link-views
44 |
45 | php artisan laravelcms --action=clear
46 |
47 | ```
48 |
49 | ## How to use it?
50 |
51 | - By default save image to your server and add rel="nofollow" to external links are enabled
52 | - You don't need to do anything after install
53 |
54 | ## How to change the settings?
55 |
56 | - You can change the settings by edit plugin.page-tab-external-image-link
57 |
58 | ```json
59 | {
60 | "plugin_name": "External Images & Links",
61 | "blade_file": "remote-image",
62 | "tab_name": "",
63 | "php_class": "Amila\\LaravelCms\\Plugins\\ExternalImageLink\\Controllers\\ExternalImageLinkController",
64 | "remote_image_to_local": {
65 | "enable": true,
66 | "exclude": [".laravelcms.tech", "localhost/", ".test", ".local"],
67 | "local_image_size": "original",
68 | "replace_fields": [
69 | "main_content",
70 | "sub_content",
71 | "extra_content_1",
72 | "extra_content_2",
73 | "extra_content_3"
74 | ]
75 | },
76 | "nofollow_external_links": {
77 | "enable": true,
78 | "exclude": ["localhost/", ".test", ".laravelcms.tech"],
79 | "rel_text": "nofollow noopener external noindex",
80 | "target": "_blank",
81 | "replace_fields": [
82 | "main_content",
83 | "sub_content",
84 | "extra_content_1",
85 | "extra_content_2",
86 | "extra_content_3"
87 | ]
88 | }
89 | }
90 | ```
91 |
92 | ## How to send http header before grab the remote image?
93 |
94 | - Examples are below:
95 |
96 | ```json
97 | "remote_image_to_local" : {
98 | "enable": true,
99 | "exclude":[".laravelcms.tech","localhost/",".test", ".local"],
100 | "local_image_size": "original",
101 | "replace_fields": ["main_content","sub_content","extra_content_1","extra_content_2","extra_content_3"],
102 | "stream_options": {
103 | ".laravelcms.tech" : {
104 | "http" : {
105 | "method" : "GET",
106 | "header" : "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:69.0) Gecko/20100101 Firefox/69.0\r\nReferer:https://www.amazon.com/"
107 | }
108 | },
109 | ".laravel.test" : {
110 | "http" : {
111 | "method" : "GET",
112 | "header" : "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.100 Safari/537.36\r\nReferer:https://www.laravelcms.tech/"
113 | }
114 | }
115 | }
116 | },
117 | ```
118 |
119 | ## Improve this plugin & documents
120 |
121 | - You are very welcome to improve this plugin and how to use documents
122 |
123 | ## License
124 |
125 | - This Amila Laravel CMS plugin is an open-source software licensed under the MIT license.
126 |
--------------------------------------------------------------------------------
/src/Controllers/ExternalImageLinkController.php:
--------------------------------------------------------------------------------
1 | helper = new LaravelCmsHelper();
17 | }
18 |
19 | public function checkUser()
20 | {
21 | // return true;
22 | if (! $this->user) {
23 | $this->user = $this->helper->hasPermission();
24 | }
25 | }
26 |
27 | // public function create()
28 | // {
29 | // }
30 |
31 | public function edit($id, $page)
32 | {
33 | // uncomment exit() line to make sure your plugin method invoked
34 | // please check the php_class value if not invoked
35 |
36 | //exit('Looks good, the plugin\'s edit() method invoked. id=' . $id . '