Jump to:

5450 Posts in 1672 Topics by 1197 members

Customising the CMS

SilverStripe Forums » Customising the CMS » Size of ImageField thumbnail in Backend

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 647 Views
  • Pipifix
    Avatar
    Community Member
    54 Posts

    Size of ImageField thumbnail in Backend Link to this post

    Hi everybody.

    The goal:
    My client want a bigger thumbnail of the image attached to a dataobject.

    What I've done so far:
    The dataobjectitems are houses with a bunch of values. The image is bind with static $has_one = array('Image' => 'Image'   );
    The imagefield is generated in getCMSFields with $fields->addFieldToTab("Root.Main", new ImageField('Image', 'Bild des Objektes', Null, Null, Null, 'images-immodatabase'));

    My question is:
    How to alter the size of the allready attached image. Is there a simple config line? Or do i have to edit the core (Imagefield)?
    Thanks for your help.

    Pipifix.

  • Pipifix
    Avatar
    Community Member
    54 Posts

    Re: Size of ImageField thumbnail in Backend Link to this post

    bump

  • novaweb
    Avatar
    Community Member
    109 Posts

    Re: Size of ImageField thumbnail in Backend Link to this post

    Pipifix,

    Not sure if this answers your question, but in your template you can call Graphic Draw functions via SilverStripe.

    In your template:

    $Image.SetWidth(250)

    See: http://api.silverstripe.org/2.4/sapphire/filesystem/Image.html for a list of available methods on Image objects.

    Cheers,
    Josh

  • novaweb
    Avatar
    Community Member
    109 Posts

    Re: Size of ImageField thumbnail in Backend Link to this post

    Let me know if you were wanting to increase the image size in the back end (CMS), and not on the front end (template) of your site.

  • Pipifix
    Avatar
    Community Member
    54 Posts

    Re: Size of ImageField thumbnail in Backend Link to this post

    Thanks novaweb.

    I meant the thumbnail preview in the ModelAdmin (=Backend).

    Pipifix

  • Pipifix
    Avatar
    Community Member
    54 Posts

    Re: Size of ImageField thumbnail in Backend Link to this post

    Nobody?

  • zenmonkey
    Avatar
    Community Member
    524 Posts

    Re: Size of ImageField thumbnail in Backend Link to this post

    I've done custom thumbnails in modeladmin table.

    //first add you're custom thumbnail field to the Summary Field
    static $summary_fields = array('Thumb');

    //then create a a custom getter for it
    public function getThumb(){
    $image = DataObject::get_by_id("File", $this->ImageID);
    if ($image){
    return $image->setWidth(50);
    } else {
    return "No Image Available";
    }
    }


    I'm assuming that your image is held under ImageID, and for the return function you can use any of the standard image functions.

    Now this won't change the size of the thumbnail in the CMS ImageField, unfortunately the current ImageFIeld doesn't allow you to customize the thumbnail size

    I think I also saw a tutorial for this on SSBits.com, not sure if their implementation is better. I had a solution when by the time I saw it there

    Cheers

    647 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.