Jump to:

22997 Posts in 11844 Topics by 2828 members

General Questions

SilverStripe Forums » General Questions » ss3 gallery - upload all images at once

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

Page: 1 2
Go to End
Author Topic: 1657 Views
  • Optic Blaze
    Avatar
    Community Member
    153 Posts

    Re: ss3 gallery - upload all images at once Link to this post

    Hi there,

    I have packaged a version that works for SS 3.05 with the bulk editing and upload modules as well see here:
    http://www.silverstripe.org/all-other-modules/show/20465?start=64#post323169

    You can also check out it on Github:
    https://github.com/OpticBlaze/ss3Gallery

    Hope it helps

  • merrick_sd
    Avatar
    Community Member
    89 Posts

    Re: ss3 gallery - upload all images at once Link to this post

    i have a similar setup to http://www.silverstriperesources.com/articles/how-to-make-a-photo-gallery-in-silverstripe-3/

    its all working fine except the bulk upload option. its says its uploaded and i click save and then save and finish and the data objects get added, but no images are uploaded.

    If i add one at a time it works fine.

    ClientImage

    <?php

    class ClientImage extends DataObject {

       public static $db = array(   
          'Title' => 'Varchar',
          'LinkUsage' => 'Text',
          'IconHyperLink' => 'Text',
          'SortOrder' => 'Int'
       );

       public static $has_one = array(
        'Image' => 'Client_Image',
        'ClientPage' => 'ClientPage',   
       );

       static $singular_name = 'ClientImage';
       static $plural_name = 'ClientImages';
       
       public function getCMSFields() {
          $fields = parent::getCMSFields();
          $fields->removeFieldFromTab("Root.Main","ClientPageID");
          $fields->removeFieldFromTab("Root.Main","SortOrder");
          
          $fields->addFieldToTab('Root.Main',
          $uploadField =new UploadField('Image','Gallery Image'));
          $uploadField->setFolderName('Client');
          
          $fields->addFieldToTab('Root.Main', new OptionsetField(
           $name = 'LinkUsage',
           $title = 'Link Usage',
           $source = array('NONE' => "NONE", 'External' => "EXTERNAL"),
           $value = "1"
           ));
          
          $ExternalURLField = new TextField('IconHyperLink', 'HyperLink');
          $fields->addFieldToTab('Root.Main',$ExternalURLField );
          $ExternalURLField->setValue('http://');
       
          return $fields;      
       }

       public static $summary_fields = array(
    'ID' => 'ID',
        'Title' => 'Title',
        'Thumbnail' => 'Thumbnail',
       );

       public function getThumbnail() {
       return $this->Image()->CMSThumbnail();
       }

    }

    class Client_Image extends Image {
       
       static $db = null;
       
       function generateRatioClientImage($gd) {
          $gd->setQuality(100);
       return    $gd->resizeRatio(370,185);    
       }   
    }

    ClientPage

    <?php
    class ClientPage extends Page {

       public static $db = array(
       );

       public static $has_one = array(
       );
       
       public static $has_many = array(
          'ClientImages' => 'ClientImage'
       );
          
          
       static $icon = "mysite/images/icons/clients.png";
       static $description = 'Page with images holder for clients';

       static $singular_name = 'ClientPage';
       static $plural_name = 'ClientPages';
       
       public function getCMSFields() {

          $fields = parent::getCMSFields();

             $gridFieldConfig = GridFieldConfig_RecordEditor::create();
             $gridFieldConfig->addComponent(new GridFieldBulkEditingTools());
             $gridFieldConfig->addComponent(new GridFieldBulkImageUpload());
             $gridFieldConfig->addComponent(new GridFieldSortableRows('SortOrder'));
       
             $gridfield = new GridField("ClientImages", "Client Images", $this->ClientImages()->sort("SortOrder"), $gridFieldConfig);
                
          $fields->addFieldToTab('Root.ClientImages', $gridfield);
          
          return $fields;
          
    }

       
    }

    class ClientPage_Controller extends Page_Controller {

       public static $allowed_actions = array (
       );
       

       public function getClientImages() {
          return $this->ClientImages()->sort("SortOrder");
       }
       
       
       public function init() {
          parent::init();

       }

    }

    1657 Views
Page: 1 2
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.