Joomla-cms: [4.0] Media Manager - plug in media-action/resize - file sizes

Created on 7 Oct 2019  路  8Comments  路  Source: joomla/joomla-cms

Is your feature request related to a problem? Please describe.

Did you know that you can set max-width and max height for image uploads (and edited/resized images) in the action/resize plug-in?
If you set one or both of those parameters, your concern is probably not primarily the size in pixel but the resulting bytes.
As no quality parameters are set, the resulting file size in bytes most often is much larger than the original upload. Of course depending on the size and the compression of the original.

Describe the solution you'd like

Set quality parameters for jpeg and png files when resizing with PHP.

Additional context

I have edited and tested code and can make a PR, if you agree to the issue.

No Code Attached Yet

All 8 comments

can be a good feature

this would be the best feature imho :)

@schnuti please make a PR this is big joomla issue and should be fixed asap :)

now we have big problem with 9 MB image uploads :(

I am very glad that you try to fix this :)

@Milglius Did you test to activate the "batch"-tab parameters with max width and height? Would be interesting to know the original and resized sizes in bytes using your large images as is.

I'll add a PR with compression (=quality) parameters ASAP.

No, if you need I try to test this, but I do not know how to activate the "batch"-tab parameters with max width and height?

Thanks @schnuti I'll try to test PR with compression (=quality) parameters ASAP.

@schnuti I can't find your PR, have you submitted it ?

Can someone point me where is the PR with compression (=quality) parameters schnuti wanted to submit? Or is it abandoned or is schnuti still working on it?

Please add the file renaming code to the image editing plugin.
I used to write myself a plugin J3 for renaming uploaded photos.
So that test editors and creators of unique content don't have problems with photo names when they suddenly have the same file name.
To prefix the file name with the date and material ID.
So that everything happens automatically.

use Joomla\CMS\Factory as JFactory;
use Joomla\CMS\Plugin\CMSPlugin as JPlugin;
class plgSystemImageRename extends JPlugin {
    public function __construct(&$subject, $config=array()) 

        $image_rename = $this->params->get("image_auto_rename",FALSE);            
        if(empty($image_rename))            return; 

        $this->input = JFactory::getApplication()->input; 
    $files2        = $this->input->files->get('Filedata', array(), 'array');     

        if(empty($files2) && empty($_FILES['Filedata']))            return;

        if(is_array($_FILES['Filedata']['name'])){// && isset($file['name'])
            foreach ($_FILES['Filedata']['name'] as $i => &$file)
                $_FILES['Filedata']['name'][$i] = $this->getNewName($_FILES['Filedata']['name'][$i]);
        }
        elseif(is_string($_FILES['Filedata']['name'])){
            $_FILES['Filedata']['name'] = $this->getNewName($_FILES['Filedata']['name']);
        }

        if(empty($files2))                return;

        if(isset($files2['name'])){
             $files2['name'] = $this->getNewName($files2['name']);
        }
        elseif (isset($files2[0]['name'])) {
            foreach ($files2 as $i => &$file)
                $file['name'] = $this->getNewName($file['name']);
        }
    }
    public function getNewName($str = ''){ 
        $image_date_rename = $this->params->get("image_date_rename",FALSE);
        $image_format_rename = $this->params->get("image_format_rename","Ymd_");
            if($image_date_rename == 2 && $image_format_rename)
                $str = date($image_format_rename).$str;
            elseif($image_date_rename)
                $str = date("Ymd_").$str;
            $str = str_replace(' ', '_', $str);
            $str = str_replace('-', '_', $str);
            $str = JFactory::getLanguage()->transliterate($str);  
            return $str;
    }
}

@korenevskiy

Please don't mix different issues. You have posted your request already at https://github.com/joomla/joomla-cms/issues/28792#issuecomment-619999468 . This issue here is about quality settings for resized images.

Thank you

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Hils picture Hils  路  5Comments

Shazrina1994 picture Shazrina1994  路  4Comments

brianteeman picture brianteeman  路  6Comments

wilsonge picture wilsonge  路  4Comments

chmst picture chmst  路  5Comments