1
0
mirror of https://github.com/flextype/flextype.git synced 2025-08-12 16:14:16 +02:00

Flextype Core: Glide/Intervention Image Implementation #61

- New settings with predefined values added

entries:
  media:
    upload_images_quality: 70
    upload_images_width: 1600
    upload_images_height: 0
This commit is contained in:
Awilum
2019-01-05 23:37:48 +03:00
parent e29eee8489
commit e6e1262dd1
2 changed files with 23 additions and 5 deletions

View File

@@ -39,6 +39,10 @@ locale: "en"
# The default page to use for the homepage.
entries:
main: home
media:
upload_images_quality: 70
upload_images_width: 1600
upload_images_height: 0
error404:
title: "Error 404"
description: "We're sorry but the page you are looking for doesn't appear to exist!"
@@ -61,3 +65,5 @@ cache:
# Define the file types (extensions to be exact) that are acceptable for upload.
accept_file_types: [ gif, jpg, jpeg, png, ico, zip, tgz, txt, md, doc, docx, pdf, epub, xls, xlsx, ppt, pptx, mp3, ogg, wav, m4a, mp4, m4v, ogv, wmv, avi, webm, svg]
# Define settings for media

View File

@@ -469,13 +469,25 @@ class EntriesManager
$img = Image::make($file);
// now you are able to resize the instance
$img->resize(1600, null, function ($constraint) {
$constraint->aspectRatio();
$constraint->upsize();
});
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, 70);
$img->save($file, Registry::get('settings.entries.media.upload_images_quality'));
// destroy
$img->destroy();