Results 1 to 4 of 4

Thread: Image width and height by default (tl_news.php)

  1. #1
    User
    Join Date
    05-02-10.
    Posts
    121

    Default Image width and height by default (tl_news.php)

    Code:
    		'size' => array
    		(
    			'label'                   => &$GLOBALS['TL_LANG']['tl_content']['size'],
    			'exclude'                 => true,
    			'inputType'               => 'imageSize',
    			'options'                 => array('crop', 'proportional', 'box'),
    			'reference'               => &$GLOBALS['TL_LANG']['MSC'],
    			'eval'                    => array('rgxp'=>'digit', 'nospace'=>true, 'tl_class'=>'w50')
    		),
    how make Image width and height by default = 100x100 crop ?

    'dafault' => array('width'=>100,'height'=>100,'options'=>'crop' ),
    this not work
    sorry for my english

  2. #2
    Experienced user
    Join Date
    08-21-09.
    Posts
    563

    Default Re: Image width and height by default (tl_news.php)

    Try serializing it:
    Code:
    'default' => serialize(array('100', '100', 'crop'));
    For later versions of Contao, the cropping options changed, so it would be something like this:
    Code:
    'default' => serialize(array('100', '100', 'center_center'));
    Just keep in mind that if it does work, it will only work for new records and not when you edit an existing one (even if you didn't choose to add an image or left the width/height fields blank).

    For the "100x100 crop" -- is that just a default that a user can override, or do you want to force those values?

    If you want to force them, another way to go about it is to hide the 'size' field completely in permissions, and then generate a 100x100 cropped image in your news template with an insert tag:
    Code:
    {{image::<?php echo $this->src?width=100&height=100&mode=crop&alt=<?php echo $this->alt; ?>}}
    Brian

  3. #3
    User
    Join Date
    05-02-10.
    Posts
    121

    Default Re: Image width and height by default (tl_news.php)

    Medianomaly, thanks.

    this works

    Code:
    'default'                 => array('100', '100', 'crop'),
    serialize not need
    sorry for my english

  4. #4
    Experienced user
    Join Date
    08-21-09.
    Posts
    563

    Default Re: Image width and height by default (tl_news.php)

    Nice!

    Good to know (that serialize isn't needed), thanks.
    Brian

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •