Changeset 17310


Ignore:
Timestamp:
Aug 2, 2012, 4:30:30 PM (12 years ago)
Author:
mistic100
Message:

-restore option to add film frame effect (improved)
-update mimetypes to avoid double frames

Location:
extensions/gvideo
Files:
1 added
14 edited

Legend:

Unmodified
Added
Removed
  • extensions/gvideo/admin/add.php

    r17307 r17310  
    5757    if (count($page['errors']) == 0)
    5858    {
     59      if (isset($_POST['add_film_frame']))
     60      {
     61        add_film_frame($thumb_source);
     62      }
     63     
    5964      // add image and update infos
    6065      $image_id = add_uploaded_file($thumb_source, $thumb_name, array($_POST['category']));
  • extensions/gvideo/admin/template/add.tpl

    r17307 r17310  
    44jQuery("input[data-toggle]").change(function() {
    55  $('#'+ $(this).data('toggle')).toggle();
     6});
     7jQuery(".showInfo").tipTip({
     8  delay: 0,
     9  fadeIn: 200,
     10  fadeOut: 200,
     11  maxWidth: '300px',
     12  defaultPosition: 'right'
    613});
    714{/literal}{/footer_script}
     
    4047    </li>
    4148    <li>
    42         <span class="property">{'Author'|@translate}</span>
    43         <label><input type="radio" name="author_server" value="true" {if $POST.author_server != 'false'}checked="checked"{/if} data-toggle="author"> {'From the video'|@translate}</label>
    44         <label><input type="radio" name="author_server" value="false" {if $POST.author_server == 'false'}checked="checked"{/if} data-toggle="author"> {'Change'|@translate}</label>
     49      <span class="property">{'Author'|@translate}</span>
     50      <label><input type="radio" name="author_server" value="true" {if $POST.author_server != 'false'}checked="checked"{/if} data-toggle="author"> {'From the video'|@translate}</label>
     51      <label><input type="radio" name="author_server" value="false" {if $POST.author_server == 'false'}checked="checked"{/if} data-toggle="author"> {'Change'|@translate}</label>
    4552    </li>
    4653    <li {if $POST.author_server != 'false'}style="display:none;"{/if} id="author">
     
    5865    </li>
    5966    <li>
    60       <label>
    61         <span class="property">{'Thumbnail'|@translate}</span>
    62         <label><input type="radio" name="thumbnail_server" value="true" checked="checked" data-toggle="thumbnail_src"> {'From the video'|@translate}</label>
    63         <label><input type="radio" name="thumbnail_server" value="false" data-toggle="thumbnail_src"> {'Change'|@translate}</label>
    64       </label>
     67      <span class="property">{'Thumbnail'|@translate}</span>
     68      <label><input type="radio" name="thumbnail_server" value="true" checked="checked" data-toggle="thumbnail_src"> {'From the video'|@translate}</label>
     69      <label><input type="radio" name="thumbnail_server" value="false" data-toggle="thumbnail_src"> {'Change'|@translate}</label>
    6570    </li>
    6671    <li id="thumbnail_src" style="display:none;">
     
    7075      {'Maximum file size: %sB.'|@translate|@sprintf:$upload_max_filesize_shorthand} {'Allowed file types: %s.'|@translate|@sprintf:'jpg, png, gif'}
    7176      <input type="hidden" name="MAX_FILE_SIZE" value="{$upload_max_filesize}">
     77    </li>
     78    <li>
     79      <span class="property">&nbsp;</span>
     80      <label><input type="checkbox" name="add_film_frame" value="true"> {'Add film effect'|@translate} </label>
     81      <a class="showInfo" title="<img src='{$GVIDEO_PATH}admin/template/example-frame.jpg'>">i</a>
    7282    </li>
    7383  </ul> 
  • extensions/gvideo/admin/template/style.css

    r17307 r17310  
    4242    visibility:hidden;
    4343  }
     44 
     45.showInfo {
     46  position:static;
     47  display:inline-block;
     48  padding:1px 7px;
     49  width:4px;
     50  height:16px;
     51  line-height:16px;
     52  font-size:0.8em;
     53}
  • extensions/gvideo/include/functions.inc.php

    r17307 r17310  
    289289}
    290290
     291/**
     292 * and film frame to an image (need GD library)
     293 * @param: string source
     294 * @param: string destination (if null, the source si modified)
     295 * @return: void
     296 */
     297function add_film_frame($src, $dest=null)
     298{
     299  if (empty($dest))
     300  {
     301    $dest = $src;
     302  }
     303 
     304  // we need gd library
     305  if (!function_exists('imagecreatetruecolor'))
     306  {
     307    if ($dest != $src) copy($src, $dest);
     308    return;
     309  }
     310 
     311  // open source image
     312  $imgExt = strtolower(get_extension($src));
     313  switch ($imgExt)
     314  {
     315    case 'jpg':
     316    case 'jpeg':
     317      $srcImage = imagecreatefromjpeg($src);
     318      break;
     319    case 'png':
     320      $srcImage = imagecreatefrompng($src);
     321      break;
     322    case 'gif':
     323      $srcImage = imagecreatefromgif($src);
     324      break;
     325    default:
     326      if ($dest != $src) copy($src, $dest);
     327      return;
     328  }
     329 
     330  // source properties
     331  $srcWidth = imagesx($srcImage);
     332  $srcHeight = imagesy($srcImage);
     333  $const = intval($srcWidth * 0.04);
     334  $bandRadius = floor($const/8);
     335
     336  // band properties
     337  $imgBand = imagecreatetruecolor($srcWidth + 6*$const, $srcHeight + 3*$const);
     338 
     339  $black = imagecolorallocate($imgBand, 0, 0, 0);
     340  $white = imagecolorallocate($imgBand, 245, 245, 245);
     341 
     342  // and dots
     343  $y_start = intval(($srcHeight + 3*$const) / 2);
     344  $aug = intval($y_start / 5) + 1;
     345  $i = 0;
     346
     347  while ($y_start + $i*$aug < $srcHeight + 3*$const)
     348  {
     349    imagefilledroundrectangle($imgBand, (3/4)*$const, $y_start + $i*$aug - $const/2, (9/4)*$const - 1, $y_start + $i*$aug + $const/2 - 1, $white, $bandRadius);
     350    imagefilledroundrectangle($imgBand, (3/4)*$const, $y_start - $i*$aug - $const/2, (9/4)*$const - 1, $y_start - $i*$aug + $const/2 - 1, $white, $bandRadius);
     351
     352    imagefilledroundrectangle($imgBand, $srcWidth + (15/4)*$const, $y_start + $i*$aug - $const/2, $srcWidth + (21/4)*$const - 1, $y_start + $i*$aug + $const/2 - 1, $white, $bandRadius);
     353    imagefilledroundrectangle($imgBand, $srcWidth + (15/4)*$const, $y_start - $i*$aug - $const/2, $srcWidth + (21/4)*$const - 1, $y_start - $i*$aug + $const/2 - 1, $white, $bandRadius);
     354
     355    ++$i;
     356  }
     357
     358  // add source to band
     359  imagecopy($imgBand, $srcImage, 3*$const, (3/2)*$const, 0, 0, $srcWidth, $srcHeight);
     360 
     361  // save image
     362  switch ($imgExt)
     363  {
     364    case 'jpg':
     365    case 'jpeg':
     366      imagejpeg($imgBand, $dest);
     367      break;
     368    case 'png':
     369      imagepng($imgBand, $dest);
     370      break;
     371    case 'gif':
     372      imagegif($imgBand, $dest);
     373      break;
     374  }
     375}
     376
     377/**
     378 * create a rectangle with round corners
     379 * http://www.php.net/manual/fr/function.imagefilledrectangle.php#42815
     380 */
     381function imagefilledroundrectangle(&$img, $x1, $y1, $x2, $y2, $color, $radius)
     382{
     383  imagefilledrectangle($img, $x1+$radius, $y1, $x2-$radius, $y2, $color);
     384 
     385  if ($radius > 0)
     386  {
     387    imagefilledrectangle($img, $x1, $y1+$radius, $x2, $y2-$radius, $color);
     388    imagefilledellipse($img, $x1+$radius, $y1+$radius, $radius*2, $radius*2, $color);
     389    imagefilledellipse($img, $x2-$radius, $y1+$radius, $radius*2, $radius*2, $color);
     390    imagefilledellipse($img, $x1+$radius, $y2-$radius, $radius*2, $radius*2, $color);
     391    imagefilledellipse($img, $x2-$radius, $y2-$radius, $radius*2, $radius*2, $color);
     392  }
     393}
     394
    291395?>
  • extensions/gvideo/language/en_UK/plugin.lang.php

    r17307 r17310  
    2020$lang['Video successfully added. <a href="%s">View</a>'] = 'Video successfully added. <a href="%s">View</a>';
    2121$lang['This element is a video added with "Embedded Video"'] = 'This element is a video added with "Embedded Video"';
     22$lang['Add film effect'] = 'Add film effect';
    2223
    2324?>
  • extensions/gvideo/language/fr_FR/plugin.lang.php

    r17307 r17310  
    2020$lang['Video successfully added. <a href="%s">View</a>'] = 'Vidéo ajoutée. <a href="%s">Voir</a>';
    2121$lang['This element is a video added with "Embedded Video"'] = 'Cet élément est une vidéo ajoutée avec "Embedded Video"';
     22$lang['Add film effect'] = 'Ajouter un effet pellicule';
    2223
    2324?>
  • extensions/gvideo/maintain.inc.php

    r17307 r17310  
    179179        $thumb_source = $conf['data_location'].get_filename_wo_extension($thumb_name).'.jpg';
    180180        copy(gvideo_path.'mimetypes/'.$video['type'].'.jpg', $thumb_source);
     181        add_film_frame($thumb_source);
    181182      }
    182183    }
Note: See TracChangeset for help on using the changeset viewer.