Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/zzdjk6/silverstripe-imagelinkupgrade
Upgrade Image Links Used In HTMLText and HTMLVar Fields
https://github.com/zzdjk6/silverstripe-imagelinkupgrade
Last synced: 20 days ago
JSON representation
Upgrade Image Links Used In HTMLText and HTMLVar Fields
- Host: GitHub
- URL: https://github.com/zzdjk6/silverstripe-imagelinkupgrade
- Owner: zzdjk6
- License: mit
- Created: 2018-10-28T11:31:47.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-10-29T11:34:07.000Z (over 6 years ago)
- Last Synced: 2024-11-11T18:45:42.986Z (3 months ago)
- Language: PHP
- Homepage:
- Size: 11.7 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# silverstripe-imagelinkupgrade
## Overview
So, you have already run `MigrateFileTask` but find that you still need to do a lot of manual work for updating the broken image links in `HTMLText` and `HTMLVarchar` fields.
Afraid ignoring some places while manual checking?
Feel frustrated when trying to find the correct image link after upgrading?
Tired of repeating yourself in such a machine-ish task?
Your assistant is here!## Explain
Then, how will this tool help you?
In a nutshell, it will find all the places where a broken image link could be replaced with a correct link in all the `HTMLText` and `HTMLVarchar` fields of `DataObject`.
How it does the job?
Take a look at `ImageLinkUpgradeTask.php`, the overall process is:1. Retrieve all `DataObject` classes contains HTMLText or HTMLVarchar field
2. Retrieve all image records in DB, get the mapping relation of ID, Filename and the accessible URL
3. Gather upgrade info by each class: which class, which field, what are the old links and their replacement for that field
4. Apply changes to the databaseMore details could be found in the code.
## How to use
Add dependency via `composer`:
```
composer require zzdjk6/silverstripe-imagelinkupgrade
```Then just run it like other tasks: `/dev/tasks/ImageLinkUpgradeTask`
## Caveats
1. Make sure you backup your database before using this tool (it will modify your database).
2. Currently, some `DataObject` will be updated several times due to class inherit (e.g., subclasses of `SiteTree`).
This issue won't affect the final result (just a version jump compare to the original one)
3. This tool keeps the `Status` of versioned `DataObject` in mind, which means if the `Live` version is not the same as the `Stage` version, only `Stage` version will be changed.