Elfinder: [php:core] allow to cancel upload on upload.presave callback

Created on 31 Jan 2019  路  4Comments  路  Source: Studio-42/elFinder

There is a way to accept only images with a minimum height and a minimum width?
Thanks

connector feature question

All 4 comments

@Doals Please try autoResize plugin.

I had already seen the plugin but only accepts maxWidth and maxHeight. What I am looking for is to avoid uploading images if it is too small (example: smaller than 200x250px). And in this case an error message (The image is too small to be uploaded)

@Doals I done. You can try with nigtly build of elFinder.

connector's bind option

'bind' => array(
    'upload.presave' => array(
        function($thash, $name, $src, $elfinder, $volume) {
            $imageType = null;
            $srcImgInfo = null;
            if (extension_loaded('fileinfo') && function_exists('mime_content_type')) {
                $mime = mime_content_type($src);
                if (substr($mime, 0, 5) !== 'image') {
                    return false;
                }
            }
            if (extension_loaded('exif') && function_exists('exif_imagetype')) {
                $imageType = exif_imagetype($src);
                if ($imageType === false) {
                    return false;
                }
            } else {
                $srcImgInfo = getimagesize($src);
                if ($srcImgInfo === false) {
                    return false;
                }
            }
            if ($srcImgInfo === null) {
                $srcImgInfo = getimagesize($src);
            }
            if ($srcImgInfo) {
                if ($srcImgInfo[0] < 200 && $srcImgInfo[1] < 250) {
                    return array('error' => array(elFinder::ERROR_UPLOAD_FILE, $name, 'The image is too small to be uploaded.'));
                }
            }
        }
    )
)

Great, thanks!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

aktolu picture aktolu  路  3Comments

nicorac picture nicorac  路  4Comments

kagagnon picture kagagnon  路  3Comments

consc198 picture consc198  路  4Comments

CodeLyokoXtEAM picture CodeLyokoXtEAM  路  3Comments