Exemplo n.º 1
0
 function renderAsThumbnailImage($options)
 {
     $thumb = new ThumbnailImage($this->getFile(), $this->getUrl(), $this->getWidth(), $this->getHeight(), $this->getPath(), $this->getPage());
     // make sure to replace 'image' css class whith 'video' css class
     // in order to make thumbnail be handled correctly by RTE
     if (isset($options['img-class'])) {
         $imgClasses = explode(' ', $options['img-class']);
         $changeIndex = array_search('image', $imgClasses);
         if ($changeIndex !== false) {
             $imgClasses[$changeIndex] = "video";
         } else {
             $imgClasses[] = "video";
         }
         $options['img-class'] = implode(' ', $imgClasses);
     } else {
         $options['img-class'] = "video";
     }
     return $thumb->toHtml(array('img-class' => $options['img-class']));
 }
 function toHtml($options = array())
 {
     global $wgOut, $wgPDBHandlerUseWebGL;
     if ($wgPDBHandlerUseWebGL && self::$serial == 0) {
         $wgOut->addModules('ext.PDBHandler');
     }
     self::$serial++;
     $id = sprintf('glmol_%d', self::$serial);
     $ret = '';
     // parameters
     if ($wgPDBHandlerUseWebGL) {
         $ret .= '<script type="text/javascript">';
         $ret .= 'if (pdbHandlerParams == undefined) var pdbHandlerParams = {};';
         $ret .= sprintf('pdbHandlerParams[\'%s\'] = %s;', $id, Xml::encodeJsVar($this->file->getUrl()));
         $ret .= '</script>';
     }
     // canvas
     $ret .= sprintf('<div id="%s" style="width:%dpx;height:%dpx;display:inline-block;">%s</div>', $id, $this->width, $this->height, parent::toHTML($options));
     return $ret;
 }
Exemplo n.º 3
0
<?php

require_once 'ThumbnailImage.class.php';
$name = 'splash-5.jpg';
$tn = new ThumbnailImage("in/{$name}");
$tn->createThumbMaintainAspect(10000, 768);
$tn->saveThumb("out/{$name}");
 /**
  * Modify thumbnail DOM
  * @param ThumbnailImage $thumbnail
  * @param array $attribs Attributes of the <img> element
  * @param array|boolean $linkAttribs Attributes of the wrapping <a> element
  */
 public static function thumbnailBeforeProduceHTML(ThumbnailImage $thumbnail, array &$attribs, &$linkAttribs)
 {
     $file = $thumbnail->getFile();
     if ($file) {
         // At the moment all classes that extend File have getWidth() and getHeight()
         // but since the File class doesn't have these methods defined, this check
         // is more future-proof
         if (method_exists($file, 'getWidth')) {
             $attribs['data-file-width'] = $file->getWidth();
         }
         if (method_exists($file, 'getHeight')) {
             $attribs['data-file-height'] = $file->getHeight();
         }
     }
     return true;
 }
Exemplo n.º 5
0
 function saveFile($file, $path, $folder)
 {
     global $s, $ThumbnailImage;
     $directorio = FilesDir . $folder . "/";
     //echo $directorio;
     if (is_uploaded_file($path)) {
         if ($file->filename && is_file($directorio . $file->filename)) {
             unlink($directorio . $file->filename);
         }
         $file->filename = $file->type . time() . "." . substr(strrchr($file->filename, "."), 1);
         mkdir_recursive($directorio, 0755);
         $ti = new ThumbnailImage();
         $ti->src_file = $path;
         $ti->dest_type = THUMB_JPEG;
         $ti->dest_file = $directorio . 'thum150-' . $file->filename;
         $ti->max_width = 150;
         $ti->max_height = 150;
         $ti->Output();
         chmod($ti->dest_file, 0755);
         $ti->dest_file = $directorio . 'thum300-' . $file->filename;
         $ti->max_width = 300;
         $ti->max_height = 300;
         $ti->Output();
         chmod($ti->dest_file, 0755);
         $ti->dest_file = $directorio . 'thum800-' . $file->filename;
         $ti->max_width = 800;
         $ti->max_height = 800;
         $ti->Output();
         chmod($ti->dest_file, 0755);
         return $file->filename;
     }
 }
Exemplo n.º 6
0
            JPath::setPermissions($mosConfig_absolute_path . '/images/jtips/' . $filename_25, 666);
        }
    }
    /**
     * This is the only part that requires actual apache access to the images directory
     * Difficult to resize an image if apache cannot write the image anywhere
     */
    $ti = new ThumbnailImage();
    $ti->src_file = $_FILES['logo']['tmp_name'];
    $ti->dest_type = THUMB_JPEG;
    $ti->dest_file = $mosConfig_absolute_path . '/images/jtips/' . $filename_100;
    $ti->max_width = 100;
    $ti->max_height = 100;
    $ti->Output();
    $ti = null;
    $ti = new ThumbnailImage();
    $ti->src_file = $_FILES['logo']['tmp_name'];
    $ti->dest_type = THUMB_JPEG;
    $ti->dest_file = $mosConfig_absolute_path . '/images/jtips/' . $filename_25;
    $ti->max_width = 25;
    $ti->max_height = 25;
    $ti->Output();
    $jTeam->logo = 'images/jtips/' . $filename;
} else {
    if (jTipsGetParam($_REQUEST, 'remove_logo', 0) == 1) {
        $jTeam->logo = '';
    }
}
if (!$jTeam->save()) {
    $message = 'Save Failed!';
} else {
 /**
  * Adds data attribute to standard image output
  * @param ThumbnailImage $thumbnail
  * @param array $attribs
  * @param array $linkAttribs
  * @return boolean
  */
 public function onThumbnailBeforeProduceHTML($thumbnail, &$attribs, &$linkAttribs)
 {
     $oFile = $thumbnail->getFile();
     $linkAttribs['data-bs-filename'] = $oFile->getName();
     $linkAttribs['data-bs-fileurl'] = $oFile->getUrl();
     return true;
 }