GithubHelp home page GithubHelp logo

Comments (4)

rik43 avatar rik43 commented on May 28, 2024 1

+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.

advoor avatar advoor commented on May 28, 2024

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.

lorado avatar lorado commented on May 28, 2024

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.

advoor avatar advoor commented on May 28, 2024

This is my next focus when I get some time (Y)

from nova-editor-js.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.