Comments (4)
+1 @lorado
without nova, i used this code:
private function deleteNotUsedImages($newBlocks, $oldBlocks)
{
$images = [];
// previous images list
foreach ($oldBlocks as $block) {
if ($block['type'] === 'image') {
$url = $block['data']['file']['url'];
$images[$url] = 1;
}
}
// exlude existed in new version
foreach ($newBlocks as $block) {
if ($block['type'] === 'image') {
$url = $block['data']['file']['url'];
unset($images[$url]);
}
}
// drop files
foreach ($images as $image => $temp) {
$file = public_path($image);
if (is_file($file)) unlink($file);
}
}
from nova-editor-js.
Thanks @Krato !
I do like the idea, however it doesn't looks like the Editor JS API can help with this as it currently stands. Raised an issue hoping they can build a configurable endpoint - i rather this be in the core then me hacking on some listeners.
I've deployed a new version which gives you the ability to specify the path and disk - please let me know if you come across any issues with this.
from nova-editor-js.
Hi @advoor,
I just thought about possible implementations... How about this idea:
Before updated content is stored in DB, determine, if there are some image blocks in old version of content, that do not exist in the new version. Then parse file path from url (and all thumbnails) and remove these files.
Actually may be simply collect all the images in old content, then remove items from this list that are used in the new content. Images that are left should be then removed from disk.
It should work
from nova-editor-js.
This is my next focus when I get some time (Y)
from nova-editor-js.
Related Issues (20)
- Error in nova 4 when attaching links that have image. HOT 3
- spatie/image ^3.0 Compatible HOT 1
- Laravel 11 Support HOT 1
- Package further updates HOT 1
- Can't extend the Editorjs
- Atribute casting HOT 1
- Wrong AllowedTags in Paragraph with Nova 4 HOT 1
- Update spatie/image HOT 2
- foreach() argument error HOT 5
- anchors not rendering HOT 4
- Embed block doesn't show HOT 4
- Something went wrong: Field `blocks` is missing HOT 4
- Error when saving the same content HOT 7
- Border top when Editor is first element in panel
- Add support for Block Tunes API? HOT 6
- generateHtmlOutput Renders encoded HTML entities HOT 3
- Throw events when an image has been uploaded
- Extend in Vite HOT 2
- Edit header toolSettings levels
- Compatibility issue with Laravel 10 HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nova-editor-js.