Restrict Image Sizes in Layouts

edited March 2015 in Feature Requests
In MY_fuel_layouts.php I have the following for my main layout:

$config['layouts']['main'] = array(
'fields' => array(
'Header' => array('type' => 'fieldset', 'label' => 'Header', 'class' => 'tab'),
'page_title' => array('label' => lang('layout_field_page_title')),
'meta_description' => array('label' => lang('layout_field_meta_description')),
'meta_keywords' => array('label' => lang('layout_field_meta_keywords')),
'header_image' => array('label' => 'Header Image', 'type' => 'image'),
'Body' => array('type' => 'fieldset', 'label' => 'Body', 'class' => 'tab'),
'heading' => array('label' => lang('layout_field_heading')),
'body' => array('label' => lang('layout_field_body'), 'type' => 'textarea', 'description' => lang('layout_field_body_description')),
'body_class' => array('label' => lang('layout_field_body_class')),
)
);

There does not seem to be a way to restrict the image size of the image field.

Is this a missing feature or missing documentation?

Thanks.

Comments

  • edited 9:22PM
    Have you seen this area in the documentation:
    http://docs.getfuelcms.com/general/forms#asset
  • edited 9:22PM
    Hello. I have problem with image
    this is my demo
    http://thietkelogon.com/service/chin-lc-truyn-thng-trc-tuyn
    image not show, my image path is {img_path(acs1.png)} but i can see that on ckeditor and preview mode.
  • edited 9:22PM
    If this is being done in a module, then in your model you'll need to include the field in the model property $parsed_fields like so:
    ... public $parsed_fields = array('content'); // fields in the database that should be parsed when outputted ...
  • edited 9:22PM
    Hi David,

    I have looked at the documentation with regards to this area here:
    http://docs.getfuelcms.com/general/forms#asset

    However, the parameters "width" and "height" are used when create_thumb is TRUE to create the thumbnail, but not restrict the uploaded image size.
  • edited March 2015
    I've also discovered that this behaviour isn't replicated in simple modules (models) when the width/height are set in a field in the form_fields() function.

    In this case, it appears that "width" and "height" are only for the thumbnail, see:

    http://docs.getfuelcms.com/general/assets

    Width: The thumbnails width (Image Specific)
    Height: The thumbnails height (Image Specific)

    This differs from the asset behaviour seen in the "forms" section previously mentioned...
  • edited 9:22PM
    Looks like there is some differences in the documentation. How it should work is if create thumb is specified, the height and width will be applied to thumbnail only. If create thumb is not checked, it should effect the image uploaded.
  • edited 9:22PM
    Thanks for getting back to me.

    The differences in the documentation also appear to be how it works.

    For example, in form_fields(), if you set the width to 1024 and the height to 768, then upload a 200 by 200 image, the image will unexpectedly resize to 1024 by 768.

    While, in layouts, it works as you would expect, where it simple returns an error when you're not using create thumb if the image is the wrong size.
  • edited 9:22PM
    What's the error message you are seeing?
  • edited 9:22PM
    The error I was seeing was:
    "The image you are attempting to upload doesn't fit into the allowed dimensions".

    However I now realise that this is a result of the assets_upload_max_width and assets_upload_max_height in MY_fuel.php.

    It seems there is no way to restrict the width/height per image, only globally.
  • edited 9:22PM
    You are correct in that those are the global maximums for image height and widths. However, in your case, you can set the max dimensions to 2000 for height and width so that the image will at least upload, then you can resize it to the dimension you want with the height and width parameters specified for the field.
Sign In or Register to comment.