示例#1
0
<?php

defined('_JEXEC') or die('Restricted access');
$item = $this->currentItem;
$watermark = $rsgConfig->get('watermark');
$imageOriginalUrl = $watermark ? waterMarker::showMarkedImage($item->name, 'original') : imgUtils::getImgOriginal($item->name);
$imageUrl = $watermark ? waterMarker::showMarkedImage($item->name) : imgUtils::getImgDisplay($item->name);
switch ($rsgConfig->get('displayPopup')) {
    //No popup
    case 0:
        ?>
					<img class="rsg2-displayImage" src="<?php 
        echo $imageUrl;
        ?>
" alt="<?php 
        echo $item->name;
        ?>
" title="<?php 
        echo $item->name;
        ?>
" />
		<?php 
        break;
        //Normal popup
    //Normal popup
    case 1:
        ?>
<a href="<?php 
        echo $imageOriginalUrl;
        ?>
" target="_blank">
示例#2
0
/**
 * Function will regenerate thumbs for a specific gallery or set of galleries
 * @todo Check if width really changed, else no resize needed. 
 * Perhaps by sampling the oldest thumb from the gallery and checking dimensions against current setting. 
 */
function executeRegenerateImages()
{
    global $rsgConfig, $mainframe;
    $error = 0;
    $gid = rsgInstance::getVar('gid', array());
    if (empty($gid)) {
        $mainframe->redirect("index2.php?option=com_rsgallery2&rsgOption=maintenance&task=regenerateThumbs", JText::_('NO_GALLERY_SELECTED'));
        return;
    }
    foreach ($gid as $id) {
        if ($id > 0) {
            //Check if resize is really needed. It takes a lot of resources when changing thumbs when dimensions did not change!
            if (!rsg2_maintenance::thumbSizeChanged($id)) {
                $mainframe->redirect("index2.php?option=com_rsgallery2&rsgOption=maintenance&task=regenerateThumbs", JText::_('THUMBNAIL_SIZE_DID_NOT_CHANGE_REGENERATION_NOT_NEEDED'));
                return;
            } else {
                $gallery = rsgGalleryManager::_get($id);
                $images = $gallery->items();
                foreach ($images as $image) {
                    $imagename = imgUtils::getImgOriginal($image->name, true);
                    if (!imgUtils::makeThumbImage($imagename)) {
                        //Error counter
                        $error++;
                    }
                }
            }
        }
    }
    if ($error > 0) {
        $msg = JText::_('MAINT_REGEN_ERRORS');
    } else {
        $msg = JText::_('MAINT_REGEN_NO_ERRORS');
    }
    $mainframe->redirect("index2.php?option=com_rsgallery2&rsgOption=maintenance&task=regenerateThumbs", $msg);
}
示例#3
0
 /**
  * Takes an image file, moves the file and adds database entry
  * @param the verified REAL name of the local file including path
  * @param name of file according to user/browser or just the name excluding path
  * @param desired category
  * @param title of image, if empty will be created from $imgName
  * @param description of image, if empty will remain empty
  * @return returns true if successfull otherwise returns an ImageUploadError
  */
 function importImage($imgTmpName, $imgName, $imgCat, $imgTitle = '', $imgDesc = '')
 {
     global $rsgConfig;
     $my =& JFactory::getUser();
     $database =& JFactory::getDBO();
     //First move uploaded file to original directory
     $destination = fileUtils::move_uploadedFile_to_orignalDir($imgTmpName, $imgName);
     if (is_a($destination, 'imageUploadError')) {
         return $destination;
     }
     $parts = pathinfo($destination);
     // If IPTC parameter in config is true and the user left either the image title
     // or description empty in the upload step we want to get that IPTC data.
     if ($rsgConfig->get('useIPTCinformation')) {
         if ($imgTitle == '' or $imgDesc == '') {
             getimagesize($destination, $imageInfo);
             if (isset($imageInfo['APP13'])) {
                 $iptc = iptcparse($imageInfo['APP13']);
                 //Get Iptc.Caption for the description (null if it does not exist)
                 $IPTCcaption = $iptc["2#120"][0];
                 //Get Iptc.ObjectName for the title
                 $IPTCtitle = $iptc["2#005"][0];
                 //If the field (description or title) in the import step is emtpy, and we have IPTC info, then use the IPTC info:
                 if ($imgDesc == '' and !is_null($IPTCcaption)) {
                     $imgDesc = $IPTCcaption;
                 }
                 if ($imgTitle == '' and !is_null($IPTCtitle)) {
                     $imgTitle = $IPTCtitle;
                 }
             }
         }
     }
     // fill $imgTitle if empty
     if ($imgTitle == '') {
         $imgTitle = substr($parts['basename'], 0, -(strlen($parts['extension']) + ($parts['extension'] == '' ? 0 : 1)));
     }
     // replace names with the new name we will actually use
     $parts = pathinfo($destination);
     $newName = $parts['basename'];
     $imgName = $parts['basename'];
     //Get details of the original image.
     $width = getimagesize($destination);
     if (!$width) {
         imgUtils::deleteImage($newName);
         return new imageUploadError($destination, JText::_('NOT AN IMAGE OR CANNOT READ') . " " . $destination);
     } else {
         //the actual image width and height and its max
         $height = $width[1];
         $width = $width[0];
         if ($height > $width) {
             $maxSideImage = $height;
         } else {
             $maxSideImage = $width;
         }
     }
     //Destination becomes original image, just for readability
     $original_image = $destination;
     // if original is wider or higher than display size, create a display image
     if ($maxSideImage > $rsgConfig->get('image_width')) {
         $result = imgUtils::makeDisplayImage($original_image, $newName, $rsgConfig->get('image_width'));
         if (!$result) {
             imgUtils::deleteImage($newName);
             return new imageUploadError($imgName, JText::_('ERROR CREATING DISPLAY IMAGE') . ": " . $newName);
         }
     } else {
         $result = imgUtils::makeDisplayImage($original_image, $newName, $maxSideImage);
         if (!$result) {
             imgUtils::deleteImage($newName);
             return new imageUploadError($imgName, JText::_('ERROR CREATING DISPLAY IMAGE') . ": " . $newName);
         }
     }
     // if original is wider or higher than thumb, create a thumb image
     if ($maxSideImage > $rsgConfig->get('thumb_width')) {
         $result = imgUtils::makeThumbImage($original_image, $newName);
         if (!$result) {
             imgUtils::deleteImage($newName);
             return new imageUploadError($imgName, JText::_('ERROR CREATING THUMB IMAGE') . ": " . $newName);
         }
     }
     // determine ordering
     $database->setQuery("SELECT COUNT(1) FROM #__rsgallery2_files WHERE gallery_id = '{$imgCat}'");
     $ordering = $database->loadResult() + 1;
     //Store image details in database
     $imgAlias = $database->getEscaped(JFilterOutput::stringURLSafe($imgTitle));
     $imgDesc = $database->getEscaped($imgDesc);
     $imgTitle = $database->getEscaped($imgTitle);
     $database->setQuery("INSERT INTO #__rsgallery2_files" . " (title, name, descr, gallery_id, date, ordering, userid, alias) VALUES" . " ('{$imgTitle}', '{$newName}', '{$imgDesc}', '{$imgCat}', now(), '{$ordering}', '{$my->id}', '{$imgAlias}')");
     if (!$database->query()) {
         imgUtils::deleteImage($newName);
         return new imageUploadError($imgName, $database->stderr(true));
     }
     //check if original image needs to be kept, otherwise delete it.
     if (!$rsgConfig->get('keepOriginalImage')) {
         JFile::delete(imgUtils::getImgOriginal($newName, true));
     }
     return true;
 }