Jump to:

3430 Posts in 1057 Topics by 734 members

Data Model Questions

SilverStripe Forums » Data Model Questions » PaddedResize in controller?

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

Page: 1
Go to End
Author Topic: 546 Views
  • nekranox
    Avatar
    Community Member
    31 Posts

    PaddedResize in controller? Link to this post

    Hey guys,

    I am currently using $image->SetWidth inside one of my PHP controllers but would like to use the same functionality that's provided by $Image.PaddedResize in the template. I couldn't find a PaddedResize method in Image.php.

    The closest I found was generateFormattedImage() which looks like it can access internal functions that might provide a padded resize. I couldn't get it to return anything sensible.

    Any ideas? Thanks,

    Robbie

    ---
    code for reference:

       public function LoadMainImages() {
          $images = DataObject::get('GalleryImage', 'GalleryImage.'.$this->ClassName.'ID='.$this->ID);
          $output = new DataObjectSet();
          foreach($images as $image) {
             $image->ImageFile = DataObject::get('File', 'File.ID='.$image->ImageFileID)->items;
             $image->ImageFile = $image->ImageFile[0]->SetWidth($this->MainImageWidth, $this->MainImageHeight);
             $image->ResizedImage = $image->ImageFile->record['Filename'];
             $output->push($image);
          }
          return $output;
       }

  • pac
    Avatar
    Community Member
    25 Posts

    Re: PaddedResize in controller? Link to this post

    $Image.PaddedImage(80, 80)
    can use a 3rd argument with the Hex background color I think

    546 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.