Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

General Questions /

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

ss3 gallery - upload all images at once


Go to End
Reply


10 Posts   2388 Views

Avatar
Optic Blaze

Community Member, 165 Posts

12 August 2013 at 12:17am

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

Avatar
merrick_sd

Community Member, 97 Posts

3 October 2013 at 2:18am

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();

   }

}

Go to Top