mirror of
https://github.com/devcode-it/openstamanager.git
synced 2025-02-16 19:40:44 +01:00
Funzione ridimensionamento immagini
This commit is contained in:
parent
8a94a728a6
commit
1809d33d6a
@ -233,6 +233,10 @@ class Upload extends Model
|
||||
{
|
||||
if ($this->isImage()) {
|
||||
// self::generateThumbnails($this);
|
||||
|
||||
if( setting('Ridimensionamento immagini') ){
|
||||
self::ridimensionaImmagini($this);
|
||||
}
|
||||
}
|
||||
|
||||
return parent::save($options);
|
||||
@ -380,4 +384,26 @@ class Upload extends Model
|
||||
});
|
||||
$img->save(slashes($directory.'/'.$info['filename'].'_thumb100.'.$info['extension']));
|
||||
}
|
||||
|
||||
protected static function ridimensionaImmagini($upload)
|
||||
{
|
||||
$info = $upload->info;
|
||||
$directory = $upload->directory;
|
||||
|
||||
$filepath = base_dir().'/'.$info['dirname'].'/'.$info['filename'].'.'.$info['extension'];
|
||||
|
||||
if (!in_array(mime_content_type($filepath), ['image/x-png', 'image/gif', 'image/jpeg'])) {
|
||||
return;
|
||||
}
|
||||
|
||||
$driver = extension_loaded('gd') ? 'gd' : 'imagick';
|
||||
ImageManagerStatic::configure(['driver' => $driver]);
|
||||
|
||||
$img = ImageManagerStatic::make($filepath);
|
||||
|
||||
$img->resize(setting('Larghezza per ridimensionamento immagini'), null, function ($constraint) {
|
||||
$constraint->aspectRatio();
|
||||
});
|
||||
$img->save(slashes($filepath));
|
||||
}
|
||||
}
|
||||
|
@ -203,3 +203,12 @@ UPDATE `zz_plugins` SET `options` = '{\"main_query\": [{\"type\": \"table\", \"f
|
||||
|
||||
-- Fix segmento Articoli disponibili
|
||||
UPDATE `zz_segments` SET `clause` = '1=1 AND `qta` > 0' WHERE `zz_segments`.`name` = 'Disponibili';
|
||||
|
||||
-- Ridimensionamento immagini
|
||||
INSERT INTO `zz_settings` (`id`, `nome`, `valore`, `tipo`, `editable`, `sezione`, `order`) VALUES
|
||||
(NULL, 'Ridimensionamento immagini', '0', 'boolean', '1', 'Generali', NULL),
|
||||
(NULL, 'Larghezza per ridimensionamento immagini', '600', 'integer', '1', 'Generali', NULL);
|
||||
|
||||
INSERT INTO `zz_settings_lang` (`id`, `id_lang`, `id_record`, `title`, `help`) VALUES
|
||||
(NULL, '1', (SELECT `id` FROM `zz_settings` WHERE `nome` = 'Ridimensionamento immagini'), 'Ridimensionamento immagini', ''),
|
||||
(NULL, '1', (SELECT `id` FROM `zz_settings` WHERE `nome` = 'Larghezza per ridimensionamento immagini'), 'Larghezza per ridimensionamento immagini', '');
|
Loading…
x
Reference in New Issue
Block a user