To participate you must create an account on apostrophenow.org. If you have already done so, click Login.

Show
Ignore:
Timestamp:
08/08/10 12:18:34 (22 months ago)
Author:
tboutell
Message:

Merged the cropping branch back to trunk:

Cropping is now available in the media repository. Every time you select an image for use on the site you have the opportunity to crop it. The image size constraints of the slot are taken into account. This means that you can satisfy a given set of constraints by cropping a wide variety of images that would not have been eligible for selection before.

Crops of existing images appear in the database as separate aMediaItem objects but do not duplicate the original image file. This means that many crops of a single source image can exist without significant overhead.

The slug field of a cropped version of an image contains cropping parameters. When rendering the image, Symfony routes spot these and crop the original file as needed.

By approaching the problem this way we have avoided the need for code that takes advantage of the media repository's image selection capabilities to change in any way in order to take advantage of cropping.

The single-image-select behavior of Apostrophe has changed to accommodate the extra cropping step. Single select for PDFs and videos still uses the selectSingle partial because they cannot be cropped.

Thanks to Spike Broehm for his contributions to the cropping project.

Fixes #227

Location:
plugins/apostrophePlugin/trunk
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • plugins/apostrophePlugin/trunk

  • plugins/apostrophePlugin/trunk/lib/action/BaseaMediaComponents.class.php

    r448 r1917  
    110110  } 
    111111 
     112  public function executeSelectMultiple($request) 
     113  { 
     114    $this->items = aMediaTools::getSelectedItems(); 
     115  } 
     116 
     117  public function executeSelectSingle($request) 
     118  { 
     119    $this->items = aMediaTools::getSelectedItems(); 
     120  } 
     121 
    112122  public function executeMultipleList($request) 
    113123  { 
    114     if (!aMediaTools::isMultiple()) 
    115     { 
    116       throw new Exception("multiple list component, but multiple is off");  
    117     } 
    118     $selection = aMediaTools::getSelection(); 
    119     if (!is_array($selection)) 
    120     { 
    121       throw new Exception("selection is not an array"); 
    122     } 
    123     // Work around the fact that whereIn doesn't evaluate to AND FALSE 
    124     // when the array is empty (it just does nothing; which is an 
    125     // interesting variation on MySQL giving you an ERROR when the  
    126     // list is empty, sigh) 
    127     if (count($selection)) 
    128     { 
    129       // Work around the unsorted results of whereIn. You can also 
    130       // do that with a FIELD function 
    131       $unsortedItems = Doctrine_Query::create()-> 
    132         from('aMediaItem i')-> 
    133         whereIn('i.id', $selection)-> 
    134         execute(); 
    135       $itemsById = array(); 
    136       foreach ($unsortedItems as $item) 
    137       { 
    138         $itemsById[$item->getId()] = $item; 
    139       } 
    140       $this->items = array(); 
    141       foreach ($selection as $id) 
    142       { 
    143         if (isset($itemsById[$id])) 
    144         { 
    145           $this->items[] = $itemsById[$id]; 
    146         } 
    147       } 
    148     } 
    149     else 
    150     { 
    151       $this->items = array(); 
    152     } 
     124    $this->items = aMediaTools::getSelectedItems(); 
     125  } 
     126   
     127  public function executeMultiplePreview() 
     128  { 
     129    $this->items = aMediaTools::getSelectedItems(); 
    153130  } 
    154131}