Studio-42 / elFinder

📁 Open-source file manager for web, written in JavaScript using jQuery and jQuery UI
https://studio-42.github.io/elFinder/
Other
4.65k stars 1.42k forks source link

Getting the path of pasted image #2689

Closed uru closed 6 years ago

uru commented 6 years ago

Hi, I have a callback function that works with uploading and pasting from Bind actions.

'bind' => array( 'upload paste' => array('smallImage'))

With this callback function, I automatically generate many different sizes of the uploaded image. While doing this, I find the path of the image with the url parameter in the $result variable. But the paste action that works with Drag&Drop has no url parameter in the $result variable. How can I get the path of an image that is copied and pasted?

nao-pon commented 6 years ago

@uru You can get URL with getContentUrl.

function smallImage($cmd, &$result, $args, $elfinder, $volume) {
    if (!empty($result['added'])) {
        foreach($result['added'] as $i => $f) {
            if (empty($f['url'])) {
                $result['added'][$i]['url'] = $volume->getContentUrl($f['hash']);
            }
        }
    }
}
uru commented 6 years ago

Thank you @nao-pon, The important point is $volume->getContentUrl() function 👍