Skip to content
Grav 2.0 is officially stable. Read the announcement →

Community guidelines

Please keep discussions civil and on-topic. Repeated violations may lead to a temporary ban.

Themes & Styling

How to prevent Grav from resizing images?

Solved by pamtbaau View solution

Started by mji 11 months ago · 2 replies · 83 views
11 months ago

Hello,

I’m having troubles with Grav as it resizes images at 1280px width at upload, and a client asked me if I can overwrite this rule. I tried to comment the following lines in the config/plugins/admin.yaml but it didn’t help :

pagemedia:

# resize_width: 1280
# resize_height: 1280
# resize_quality: 0.85

I also found some variables that may have an impact but cannot find where they’re used, in /plugins/problems/scss/_variables.scss :
// Sizes
[…]
$control-width-xs: 180px !default;
$control-width-sm: 320px !default;
$control-width-md: 640px !default;
$control-width-lg: 960px !default;
$control-width-xl: 1280px !default;
// Responsive breakpoints
$size-xs: 480px !default;
$size-sm: 600px !default;
$size-md: 840px !default;
$size-lg: 960px !default;
$size-xl: 1280px !default;
$size-2x: 1440px !default;

Is there any way to keep the original image size ?

By the way, I’m using Grav v1.7.48 and Admin v1.10.48.

Thanks a lot for your answers 🙏

11 months ago Solution

@mji, Admin's default media settings are:

YAML
pagemedia:
  resize_width: 0
  resize_height: 0
  res_min_width: 0
  res_min_height: 0
  res_max_width: 0
  res_max_height: 0
  resize_quality: 0.8

And according Admin's Extra tab:

The following settings apply to images uploaded through the page media. Resize Width / Height will automatically resize down and proportionally an image if exceeds the limits set in the inputs. Resolution min and max values define the size ranges for uploaded images. Set the fields to 0 to prevent any manipulation.

My tests confirm that images are not manipulated using the default '0' settings.

Having said that...
Grav uses so called Environmental Configuration, meaning Grav saves configs per domain being used. This means there can be configs in the following folders:

  • user/plugins/\<plugin>/
  • user/config/plugins/
  • user/env/domain.com/config/plugins
  • user/env/otherdomain.com/config/plugins
  • user/domain.com/config/plugins (old location but might still be around)
  • user/otherdomain.com/config/plugins (old location but might still be around)

Grav will first look in user/plugins/\<plugin> location, then user/config/plugins/ location and lastly in the most applicable other domain location. Settings found in the first location, will be overridden by settings in the second location, which will inturn be overridden by settings in the third location.

Do you perhaps have admin.yaml files in multiple locations? If you uncomment the settings in the domain location, Admin will fallback to the settings in the default (user/config) location.

👍 2
last edited 08/04/25 by pamtbaau
10 months ago

Hey @pamtbaau,
Thanks a lot for your answer! You’were right I had to overwrite an other file to make it work.
Now it’s all fine. Thanks again.

Suggested topics

Topic Participants Replies Views Activity
Themes & Styling · by Pedro M, 2 months ago
4 193 2 months ago
Themes & Styling · by Ian, 2 months ago
3 90 2 months ago
Themes & Styling · by Norbert, 2 years ago
11 449 3 months ago
Themes & Styling · by Lukáš Findeis, 3 months ago
0 43 3 months ago
Themes & Styling · by Sebadamus, 4 months ago
5 123 3 months ago