mirror of
https://github.com/flextype/flextype.git
synced 2025-08-10 23:24:04 +02:00
Admin Panel: Media Manager - improvements
This commit is contained in:
@@ -467,33 +467,36 @@ class EntriesManager
|
||||
|
||||
if($file !== false) {
|
||||
|
||||
// open an image file
|
||||
$img = Image::make($file);
|
||||
if (in_array(pathinfo($file)['extension'], ['jpg', 'jpeg', 'png', 'gif'])) {
|
||||
|
||||
// open an image file
|
||||
$img = Image::make($file);
|
||||
|
||||
// now you are able to resize the instance
|
||||
if (Registry::get('settings.entries.media.upload_images_width') > 0 && Registry::get('settings.entries.media.upload_images_height') > 0) {
|
||||
$img->resize(Registry::get('settings.entries.media.upload_images_width'), Registry::get('settings.entries.media.upload_images_height'), function ($constraint) {
|
||||
$constraint->aspectRatio();
|
||||
$constraint->upsize();
|
||||
});
|
||||
} elseif (Registry::get('settings.entries.media.upload_images_width') > 0) {
|
||||
$img->resize(Registry::get('settings.entries.media.upload_images_width'), null, function ($constraint) {
|
||||
$constraint->aspectRatio();
|
||||
$constraint->upsize();
|
||||
});
|
||||
} elseif (Registry::get('settings.entries.media.upload_images_height') > 0) {
|
||||
$img->resize(null, Registry::get('settings.entries.media.upload_images_height'), function ($constraint) {
|
||||
$constraint->aspectRatio();
|
||||
$constraint->upsize();
|
||||
});
|
||||
// now you are able to resize the instance
|
||||
if (Registry::get('settings.entries.media.upload_images_width') > 0 && Registry::get('settings.entries.media.upload_images_height') > 0) {
|
||||
$img->resize(Registry::get('settings.entries.media.upload_images_width'), Registry::get('settings.entries.media.upload_images_height'), function ($constraint) {
|
||||
$constraint->aspectRatio();
|
||||
$constraint->upsize();
|
||||
});
|
||||
} elseif (Registry::get('settings.entries.media.upload_images_width') > 0) {
|
||||
$img->resize(Registry::get('settings.entries.media.upload_images_width'), null, function ($constraint) {
|
||||
$constraint->aspectRatio();
|
||||
$constraint->upsize();
|
||||
});
|
||||
} elseif (Registry::get('settings.entries.media.upload_images_height') > 0) {
|
||||
$img->resize(null, Registry::get('settings.entries.media.upload_images_height'), function ($constraint) {
|
||||
$constraint->aspectRatio();
|
||||
$constraint->upsize();
|
||||
});
|
||||
}
|
||||
|
||||
// finally we save the image as a new file
|
||||
$img->save($file, Registry::get('settings.entries.media.upload_images_quality'));
|
||||
|
||||
// destroy
|
||||
$img->destroy();
|
||||
}
|
||||
|
||||
// finally we save the image as a new file
|
||||
$img->save($file, Registry::get('settings.entries.media.upload_images_quality'));
|
||||
|
||||
// destroy
|
||||
$img->destroy();
|
||||
|
||||
Notification::set('success', __('admin_message_entry_file_uploaded'));
|
||||
Http::redirect(Http::getBaseUrl().'/admin/entries/edit?entry='.Http::get('entry').'&media=true');
|
||||
} else {
|
||||
|
Reference in New Issue
Block a user