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/modules/aMedia/templates/_selectMultiple.php

    r1914 r1917  
    22  // Compatible with sf_escaping_strategy: true 
    33  $limitSizes = isset($limitSizes) ? $sf_data->getRaw('limitSizes') : null; 
     4  $items = $sf_data->getRaw('items') ? $sf_data->getRaw('items') : null; 
    45?> 
     6<?php // Known as selectMultiple for historic reasons, but we use it for both single and multiple select now that ?> 
     7<?php // we have a need for cropping which requires a pause in both cases anyway. ?> 
    58<?php use_helper('I18N') ?> 
     9<?php use_javascript("/apostrophePlugin/js/plugins/jquery.jCrop.min.js") ?> 
     10<?php use_javascript("/apostrophePlugin/js/aCrop.js") ?> 
     11<?php use_stylesheet("/apostrophePlugin/css/Jcrop/jquery.Jcrop.css") ?> 
    612<div class="a-media-select"> 
    713<?php $type = aMediaTools::getAttribute('type') ?> 
     
    915<?php $type = "media item" ?> 
    1016<?php endif ?> 
    11         <p><?php echo __('Select one or more %typeplural% by clicking on them below. Drag and drop %typeplural%  to reorder them within the list of selected items. Remove %typeplural% by clicking on the trashcan.', array('%typeplural%' => __($type . 's')), 'apostrophe') ?> 
    12   <?php if ($limitSizes): ?> 
    13   <?php echo __('Only appropriately sized %typeplural% are shown.', array('%typeplural%' => __($type . 's')), 'apostrophe') ?> 
    14   <?php endif ?> 
    15   <?php echo __('When you\'re done, click "Save."', null, 'apostrophe') ?></p> 
     17        <h3><?php echo $label ?></h3> 
    1618 
    17         <ul id="a-media-selection-list"> 
    18         <?php include_component("aMedia", "multipleList") ?> 
     19        <div id="a-media-selection-list-caption"> 
     20          <h4><?php echo __("Preview your selected image%plural% here.", array('%plural%' => aMediaTools::isMultiple() ? 's':' '), 'apostrophe') ?></h4> 
     21        </div> 
     22        <div id="a-media-selection-wrapper"> 
     23                <ul id="a-media-selection-list" style="min-height:<?php echo ($thumbHeight = aMediaTools::getSelectedThumbnailHeight()) ? $thumbHeight + 10 : 85 ?>px;"> 
     24                        <?php if($items): ?> 
     25                                <?php include_partial("aMedia/multipleList", array("items" => $items)) ?> 
     26                        <?php else: ?> 
     27                          <?php if (aMediaTools::isMultiple()): ?> 
     28                                <li class="a-media-selection-placeholder"><?php echo __('Add images to your slideshow', null, 'apostrophe') ?></li> 
     29                        <?php else: ?> 
     30                          <li class="a-media-selection-placeholder"><?php echo __('Select an image', null, 'apostrophe') ?></li> 
     31                        <?php endif ?> 
     32                        <?php endif ?> 
     33                </ul> 
     34 
     35                <?php echo jq_sortable_element("#a-media-selection-list", array("url" => "aMedia/multipleOrder")) ?> 
     36                <br class="c"/> 
     37 
     38                <div class="a-crop-workspace"> 
     39                  <ul id="a-media-selection-preview"> 
     40                        <?php include_partial("aMedia/multiplePreview", array("items" => $items)) ?> 
     41                  </ul> 
     42                  <ul class="a-controls a-media-crop-controls"> 
     43                                <li><?php echo jq_link_to_function(__("Crop", null, 'apostrophe'), "aCrop.setCrop('".url_for('aMedia/crop')."')", array("class"=>"a-btn save")) ?></li> 
     44                          <li><?php echo jq_link_to_function(__("Cancel", null, 'apostrophe'), "aCrop.resetCrop()", array("class"=>"a-btn icon a-cancel event-default")) ?></li> 
     45                  </ul> 
     46                </div> 
     47        </div> 
     48        <ul class="a-controls a-media-slideshow-controls"> 
     49                <li><?php echo link_to(aMediaTools::isMultiple() ? __("Save Slideshow", null, 'apostrophe') : __("Save Selection", null, 'apostrophe'), "aMedia/selected", array("class"=>"a-btn save big")) ?></li> 
     50          <li><?php echo link_to(__("Cancel", null, 'apostrophe'), "aMedia/selectCancel", array("class"=>"a-btn icon a-cancel big")) ?></li> 
    1951        </ul> 
    20  
    21         <?php echo jq_sortable_element("#a-media-selection-list", array("url" => "aMedia/multipleOrder")) ?> 
    22  
    23         <br class="c"/> 
    24  
    25         <ul class="a-controls a-media-slideshow-controls"> 
    26                 <li><?php echo link_to(__("Save", null, 'apostrophe'), "aMedia/selected", array("class"=>"a-btn save")) ?></li> 
    27           <li><?php echo link_to(__("Cancel", null, 'apostrophe'), "aMedia/selectCancel", array("class"=>"a-btn icon a-cancel")) ?></li> 
    28         </ul> 
    29          
    3052</div> 
    31         <br class="c"/> 
     53</div> 
     54<br class="c"/>