示例#1
0
	function generateThumbnail($originalImgPath, $thumbDir, $prefix, $thumbWidth = 0, $thumbHeight = 0, $type = 'resize', $typeParams = array(), $filters = array())
	{
		$thumbSize = AriImageHelper::getThumbnailDimension($originalImgPath, $thumbWidth, $thumbHeight);
		if (!$thumbSize['w'] || !$thumbSize['h'] || !@is_readable($originalImgPath))
			return null;

		$width = $thumbSize['w'];
		$height = $thumbSize['h'];
		$path_parts = pathinfo($originalImgPath);

		$thumbName = AriImageHelper::generateThumbnailFileName($prefix, $originalImgPath, $width, $height, $type);
		$thumbImgPath = $thumbDir . DS . $thumbName;
		if (@file_exists($thumbImgPath) && @filemtime($thumbImgPath) > @filemtime($originalImgPath))
			return $thumbName;

		if (!AriImageHelper::initAsido())
			return ;
		$thumbImg = Asido::image($originalImgPath, $thumbImgPath);
		$needResize = true;		
		
		if ($type == 'crop')
		{
			Asido::crop(
				$thumbImg,
				intval(AriUtils::getParam($typeParams, 'x', 0), 10),
				intval(AriUtils::getParam($typeParams, 'y', 0), 10),
				$width ? $width : $height,
				$height ? $height : $width
			);
			$needResize = false;
		}
		else if ($type == 'cropresize')
		{
			Asido::crop(
				$thumbImg,
				intval(AriUtils::getParam($typeParams, 'x', 0), 10),
				intval(AriUtils::getParam($typeParams, 'y', 0), 10),
				intval(AriUtils::getParam($typeParams, 'width', 0), 10),
				intval(AriUtils::getParam($typeParams, 'height', 0), 10)
			);
		}

		if ($filters)
		{
			if (AriUtils::parseValueBySample(
					AriUtils::getParam($filters, 'grayscale', false),
					false)
				)
			{
				Asido::grayscale($thumbImg);
			}
			
			$rotateFilter = AriUtils::getParam($filters, 'rotate');
			if (is_array($rotateFilter) && 
				AriUtils::parseValueBySample(
					AriUtils::getParam($rotateFilter, 'enable', false),
					false)
				)
			{
				$angle = 0;
				$rotateType = AriUtils::getParam($rotateFilter, 'type', 'fixed');
				if ($rotateType == 'random')
				{
					$startAngle = intval(AriUtils::getParam($rotateFilter, 'startAngle', 0), 10);
					$endAngle = intval(AriUtils::getParam($rotateFilter, 'endAngle', 0), 10);
					$angle = rand($startAngle, $endAngle);
				}
				else
				{
					$angle = intval(AriUtils::getParam($rotateFilter, 'angle', 0), 10);
				}

				$angle = $angle % 360;
				if ($angle != 0)
				{
					Asido::rotate($thumbImg, $angle);
				}
			}
		}

		if ($needResize)
		{
			if (!$width)
				Asido::height($thumbImg, $height);
			else if (!$height)
				Asido::width($thumbImg, $width);
			else
				Asido::resize($thumbImg, $width, $height, ASIDO_RESIZE_STRETCH);
		}

		$thumbImg->save(ASIDO_OVERWRITE_ENABLED);
		
		return $thumbName;
	}
示例#2
0
 /**
  * 上传信息图片
  * @author	肖飞
  * @param array	 	$arrFile					图片文件信息数组$_FILES
  * @param int 			$num					图片的标号(用于多图上传)
  * @param array		$FileListPicSize		缩略图压缩的尺寸(像素数组,存放目录小图s,中图m,例如:array('s'=>array(50,50),'m'=>array(100,100));)
  * @param int 			$FileSourPicSize	原图压缩的尺寸(像素数组,存放目录b,例如:array(600,600))
  * @param int			$intInfoID				相关数据记录ID,标示新增还是修改。
  * @param int			$intFetch				是否来自采集
  * @param bool		$blTime				新文件名是否使用时间戳
  * @param string		$FileExt					文件后缀名
  * @return string
  */
 public function uploadInfoImage($arrFile, $num = null, $FileListPicSize = 0, $FileSourPicSize = 0, $intInfoID = 0, $intFetch = 0, $blTime = true, $FileExt = '')
 {
     if ($arrFile['error'] != 0) {
         switch ($arrFile['error']) {
             case 1:
                 $strError = '文件超过了 php.ini 中 upload_max_filesize 选项限制的值';
                 break;
             case 2:
                 $strError = '文件的大小超过了 HTML 表单中 MAX_FILE_SIZE 选项指定的值';
                 break;
             case 3:
                 $strError = '文件只有部分被上传';
                 break;
             case 4:
                 $strError = '没有文件被上传';
                 break;
             case 6:
                 $strError = '找不到临时文件夹';
                 break;
             case 7:
                 $strError = '文件写入失败';
                 break;
         }
         check::AlertExit('文件上传错误!(' . $strError . ')', -1);
     }
     if ($arrFile['name']) {
         $strFileType = strtolower($arrFile['type']);
         if (!in_array($strFileType, array('image/jpg', 'image/jpeg', 'image/gif', 'image/pjpeg', 'image/png', 'image/x-png'))) {
             check::AlertExit('文件类型不符合要求(' . $arrFile['type'] . ')', -1);
         }
     }
     if ($intInfoID == 0) {
         $intID = $this->getMaxID();
     } else {
         $intID = $intInfoID;
     }
     $strDir = ceil($intID / $this->arrGCache['cache_filenum']);
     if (!is_dir($this->arrGPic['FileSavePath'])) {
         @mkdir($this->arrGPic['FileSavePath']);
         @chmod($this->arrGPic['FileSavePath'], 0777);
     }
     $strMakeDir = $this->arrGPic['FileSavePath'] . 'b/';
     if (!is_dir($strMakeDir)) {
         @mkdir($strMakeDir);
         @chmod($strMakeDir, 0777);
     }
     $strMakeDir = $strMakeDir . $strDir;
     if (!is_dir($strMakeDir)) {
         @mkdir($strMakeDir);
         @chmod($strMakeDir, 0777);
     }
     if ($FileExt == '') {
         $FileExt = strtolower(strrchr($arrFile['name'], '.'));
     }
     //取得上传文件扩展名
     if ($blTime) {
         $strTime = time();
     } else {
         $strTime = '';
     }
     if (!empty($num)) {
         $strPhoto = $strDir . '/' . $intID . '_' . $strTime . "_{$num}" . $FileExt;
         //存入数据库的图片访问路径
         $strPicName = $strMakeDir . '/' . $intID . '_' . $strTime . "_{$num}" . $FileExt;
         //新图片路径及名称
     } else {
         $strPhoto = $strDir . '/' . $intID . '_' . $strTime . $FileExt;
         $strPicName = $strMakeDir . '/' . $intID . '_' . $strTime . $FileExt;
     }
     if (!empty($FileListPicSize)) {
         //所有的图都生成缩略图
         $strMakeSmallDir = $this->arrGPic['FileSavePath'] . 's/';
         if (!is_dir($strMakeSmallDir)) {
             @mkdir($strMakeSmallDir);
             @chmod($strMakeSmallDir, 0777);
         }
         $strMakeSmallDir = $strMakeSmallDir . $strDir;
         if (!is_dir($strMakeSmallDir)) {
             @mkdir($strMakeSmallDir);
             @chmod($strMakeSmallDir, 0777);
         }
         $strMakeMiddleDir = $this->arrGPic['FileSavePath'] . 'm/';
         if (!is_dir($strMakeMiddleDir)) {
             @mkdir($strMakeMiddleDir);
             @chmod($strMakeMiddleDir, 0777);
         }
         $strMakeMiddleDir = $strMakeMiddleDir . $strDir;
         if (!is_dir($strMakeMiddleDir)) {
             @mkdir($strMakeMiddleDir);
             @chmod($strMakeMiddleDir, 0777);
         }
         if (!empty($num)) {
             $strSmallPicName = $strMakeSmallDir . '/' . $intID . '_' . $strTime . "_{$num}" . $FileExt;
             $strMiddlePicName = $strMakeMiddleDir . '/' . $intID . '_' . $strTime . "_{$num}" . $FileExt;
         } else {
             $strSmallPicName = $strMakeSmallDir . '/' . $intID . '_' . $strTime . $FileExt;
             $strMiddlePicName = $strMakeMiddleDir . '/' . $intID . '_' . $strTime . $FileExt;
         }
         $arrTemp = getimagesize($arrFile['tmp_name']);
         $arrImageInfo["width"] = $arrTemp[0];
         $arrImageInfo["height"] = $arrTemp[1];
         if (is_array($FileListPicSize)) {
             //生成s小缩略图
             if (!empty($FileListPicSize['s'])) {
                 Asido::Driver('gd');
                 $i1 = Asido::Image($arrFile['tmp_name'], $strSmallPicName);
                 if ($FileListPicSize['s'][0] == 0) {
                     //小图宽0
                     if ($FileListPicSize['s'][1] > 0) {
                         Asido::height($i1, $FileListPicSize['s'][1]);
                         $i1->save(ASIDO_OVERWRITE_ENABLED);
                     }
                 } elseif ($FileListPicSize['s'][1] == 0) {
                     //小图高0
                     Asido::width($i1, $FileListPicSize['s'][0]);
                     $i1->save(ASIDO_OVERWRITE_ENABLED);
                 } elseif (Asido::resize($i1, $FileListPicSize['s'][0], $FileListPicSize['s'][1], $this->arrGPic['zoomMode'])) {
                     $i1->save(ASIDO_OVERWRITE_ENABLED);
                 } else {
                     check::AlertExit($strSmallPicName . '缩略图生成错误!', -1);
                 }
             }
             //生成m中缩略图
             if (!empty($FileListPicSize['m'])) {
                 Asido::Driver('gd');
                 $i1 = Asido::Image($arrFile['tmp_name'], $strMiddlePicName);
                 if ($FileListPicSize['m'][0] == 0) {
                     if ($FileListPicSize['m'][1] > 0) {
                         Asido::height($i1, $FileListPicSize['m'][1]);
                         $i1->save(ASIDO_OVERWRITE_ENABLED);
                     }
                 } elseif ($FileListPicSize['m'][1] == 0) {
                     Asido::width($i1, $FileListPicSize['m'][0]);
                     $i1->save(ASIDO_OVERWRITE_ENABLED);
                 } elseif (Asido::resize($i1, $FileListPicSize['m'][0], $FileListPicSize['m'][1], $this->arrGPic['zoomMode'])) {
                     $i1->save(ASIDO_OVERWRITE_ENABLED);
                 } else {
                     check::AlertExit($strMiddlePicName . '缩略图生成错误!', -1);
                 }
             }
         } else {
             if (!empty($FileListPicSize)) {
                 check::AlertExit('缩略图的定义格式已经升级,请检查var.inc.php中$arrGPic[FileListPicSize]的定义!', -1);
             }
         }
     }
     if (!empty($FileSourPicSize)) {
         //原图容量>最大容量设定,就自动压缩原图
         if ($intFetch) {
             copy($arrFile['tmp_name'], $strPicName);
         } else {
             move_uploaded_file($arrFile['tmp_name'], $strPicName);
         }
         if (is_array($FileSourPicSize)) {
             Asido::Driver('gd');
             $i1 = Asido::Image($strPicName, $strPicName);
             if ($FileSourPicSize[0] == 0) {
                 //设定宽=0,则不定宽,定高压缩
                 if ($FileSourPicSize[1] > 0 && $FileSourPicSize[1] < $arrImageInfo['height']) {
                     Asido::height($i1, $FileSourPicSize[1]);
                     if ($this->arrGPic['waterMark']) {
                         Asido::watermark($i1, __WEB_ROOT . "/data/" . $this->arrGPic['waterImage'], $this->arrGPic['waterPos'], ASIDO_WATERMARK_SCALABLE_ENABLED, 0.5);
                     }
                     $i1->save(ASIDO_OVERWRITE_ENABLED);
                 }
                 return $strPhoto;
             } elseif ($FileSourPicSize[1] == 0) {
                 //设定高=0,则不定高,定宽压缩
                 if ($FileSourPicSize[0] > 0 && $FileSourPicSize[0] < $arrImageInfo['width']) {
                     Asido::width($i1, $FileSourPicSize[0]);
                     if ($this->arrGPic['waterMark']) {
                         Asido::watermark($i1, __WEB_ROOT . "/data/" . $this->arrGPic['waterImage'], $this->arrGPic['waterPos'], ASIDO_WATERMARK_SCALABLE_ENABLED, 0.5);
                     }
                     $i1->save(ASIDO_OVERWRITE_ENABLED);
                 }
                 return $strPhoto;
             } elseif (Asido::resize($i1, $FileSourPicSize[0], $FileSourPicSize[1], $this->arrGPic['zoomMode'])) {
                 //定宽,定高压缩
                 if ($this->arrGPic['waterMark']) {
                     Asido::watermark($i1, __WEB_ROOT . "/data/" . $this->arrGPic['waterImage'], $this->arrGPic['waterPos'], ASIDO_WATERMARK_SCALABLE_ENABLED, 0.5);
                 }
                 $i1->save(ASIDO_OVERWRITE_ENABLED);
                 return $strPhoto;
             } else {
                 check::AlertExit($strPicName . '文件上传错误!', -1);
             }
         } else {
             if (!empty($FileSourPicSize)) {
                 check::AlertExit('原图的定义格式已经升级,请检查var.inc.php中$arrGPic[FileSourPicSize]的定义!', -1);
             }
         }
     } else {
         //原图容量<=最大容量设定,就不压缩原图
         if ($intFetch) {
             if (copy($arrFile['tmp_name'], $strPicName)) {
                 return $strPhoto;
             } else {
                 echo $strPicName . '文件上传错误!';
                 exit;
             }
         } else {
             if (move_uploaded_file($arrFile['tmp_name'], $strPicName)) {
                 return $strPhoto;
             } else {
                 check::AlertExit($strPicName . '文件上传错误!', -1);
             }
         }
     }
 }
                         Asido::resize($img, $previewWidth, $previewHeight, ASIDO_RESIZE_STRETCH);
                     } else {
                         if (strstr($convertImage, 'rotate')) {
                             $rotateAttrs = explode(':', $convertImage);
                             if (!$rotateAttrs[1]) {
                                 $rotateAttrs[1] = 90;
                             }
                             Asido::Rotate($img, $rotateAttrs[1]);
                         } else {
                             if (!$previewWidth) {
                                 Asido::height($img, $previewHeight);
                             } else {
                                 if (!$previewHeight) {
                                     Asido::width($img, $previewWidth);
                                 } else {
                                     Asido::resize($img, $previewWidth, $previewHeight, ASIDO_RESIZE_STRETCH);
                                 }
                             }
                         }
                     }
                 }
                 $img->save(ASIDO_OVERWRITE_ENABLED);
             }
             $imagesCode .= JURI::root() . "images/artsexylightbox_tmp/{$generatedThumbName}' ";
         }
     } else {
         $imagesCode .= JURI::root() . "{$path}/{$entry}' ";
     }
 }
 if ($previewHeight) {
     $imagesCode .= " height='{$previewHeight}' ";
示例#4
0
 /**
  * General resize for image
  *
  * @since	1.0
  * @access	public
  * @param	int			The target width.
  * @param	int			The target height.
  * @param	int			The resize mode.
  * @return	SocialImage	Returns itself for chaining.
  */
 public function resize($width = null, $height = null, $mode = ASIDO_RESIZE_PROPORTIONAL)
 {
     // Resize
     $this->adapter->resize($this->image, $width, $height, $mode);
     return $this;
 }
示例#5
0
    function getSexyLightboxCode($id, $finalParams, $content = '')
    {
        $path = $finalParams['path'];
        $theme = $finalParams['theme'];
        $previewWidth = $finalParams['previewWidth'];
        $previewHeight = $finalParams['previewHeight'];
        $noConflict = $finalParams['noConflict'];
        $flickr = $finalParams['flickr'];
        $thumbnailPath = $finalParams['thumbnailPath'];
        $singleImage = $finalParams['singleImage'];
        $singleText = $finalParams['singleText'];
        $thumbnailPreviewCount = $finalParams['thumbnailPreviewCount'];
        $popup = $finalParams['popup'];
        $autoGenerateThumbs = $finalParams['autoGenerateThumbs'];
        $flickrNumberOfImages = $finalParams['flickrNumberOfImages'];
        $numberOfImages = $finalParams['numberOfImages'];
        $sort = $finalParams['sort'];
        if (!$flickrNumberOfImages) {
            $flickrNumberOfImages = 20;
        }
        $imagesCode = '';
        $jsCode = '<script type="text/javascript" charset="utf-8">';
        if ($noConflict) {
            $document =& JFactory::getDocument();
            $document->addCustomTag('<script type="text/javascript" charset="utf-8">jQuery.noConflict();</script>');
        }
        $jsonHandler = new ART_Services_JSON(SERVICES_JSON_LOOSE_TYPE);
        $dFP = !empty($finalParams) ? $jsonHandler->encode($finalParams) : '';
        if ($path) {
            if ($thumbnailPath) {
                $thumbs = array();
                $thumb_directory_stream = @opendir(JPATH_SITE . DS . $thumbnailPath . DS);
                if ($thumb_directory_stream) {
                    while ($entry = readdir($thumb_directory_stream)) {
                        if ($entry != '.' && $entry != '..' && plgContentartsexylightbox::isImage($thumbnailPath . $entry)) {
                            $thumbs[$entry] = $entry;
                        }
                    }
                }
            }
            $file_handle = @fopen(JPATH_SITE . DS . $path . DS . "artsexylightbox.txt", "rb");
            $descriptionArray = array();
            if ($file_handle) {
                while (!feof($file_handle)) {
                    $line_of_text = fgets($file_handle);
                    $parts = explode('=', $line_of_text);
                    $descriptionArray[$parts[0]] = $parts[1];
                }
                fclose($file_handle);
            }
            $id = uniqid('artgallery_', false);
            $jsCode .= 'if (!window.sexylightboxEnabled) {jQuery(document).ready(function(){SexyLightbox.initialize(' . $dFP . ')});} if (!window.sexylightboxEnabled) {window.sexylightboxEnabled = true;}</script>';
            $directory_stream = @opendir(JPATH_SITE . DS . $path . DS) or die("Could not open a directory stream for <i>" . JPATH_SITE . DS . $path . DS . "</i>");
            $filelist = array();
            while ($entry = readdir($directory_stream)) {
                if ($entry != '.' && $entry != '..' && plgContentartsexylightbox::isImage($path . $entry)) {
                    $filelist[] = $entry;
                }
            }
            if ($sort == 'desc') {
                usort($filelist, 'artSLFileDescSort');
            } else {
                usort($filelist, 'artSLFileAscSort');
            }
            if ($thumbnailPreviewCount && $thumbnailPreviewCount > count($filelist)) {
                $thumbnailPreviewCount = count($filelist);
            }
            if ($singleImage) {
                $imagesCode .= "<a onclick='jQuery(\"a[rel*=" . $id . "]\").eq(0).click();return false;'><img class='artsexylightbox_singleimage' src='" . JURI::root() . $singleImage . "'";
                if ($previewHeight) {
                    $imagesCode .= " height='{$previewHeight}'";
                }
                if ($previewWidth) {
                    $imagesCode .= " width='{$previewWidth}' ";
                }
                $imagesCode .= " /></a>";
            } else {
                if ($singleText) {
                    $imagesCode .= "<a onclick='jQuery(\"a[rel*=" . $id . "]\").eq(0).click();return false;'><span class='artsexylightbox_singletext'>" . $singleText . "</span></a>";
                } else {
                    if ($thumbnailPreviewCount && $thumbnailPreviewCount > 0) {
                        $thumbsCount = 0;
                        while ((list($key, $entry) = each($filelist)) && $thumbsCount < $thumbnailPreviewCount) {
                            if ($entry != '.' && $entry != '..' && plgContentartsexylightbox::isImage($path . $entry)) {
                                $imagePath = JPATH_SITE . DS . $path . DS . $entry;
                                if ($thumbs && isset($thumbs[$entry])) {
                                    $imagesCode .= "<a onclick='jQuery(\"a[rel*=" . $id . "]\").eq(0).click();return false;'><img class='artsexylightbox_singleimage' src='" . JURI::root() . $thumbnailPath . '/' . $entry . "'";
                                } else {
                                    $imagesCode .= "<a onclick='jQuery(\"a[rel*=" . $id . "]\").eq(0).click();return false;'><img class='artsexylightbox_singleimage' src='" . JURI::root() . $path . '/' . $entry . "'";
                                }
                                if ($previewHeight) {
                                    $imagesCode .= " height='{$previewHeight}'";
                                }
                                if ($previewWidth) {
                                    $imagesCode .= " width='{$previewWidth}' ";
                                }
                                $imagesCode .= " /></a>";
                                $thumbsCount++;
                            }
                        }
                    }
                }
            }
            reset($filelist);
            $imagesCount = 0;
            while ((list($key, $entry) = each($filelist)) && ($numberOfImages > 0 ? $imagesCount < $numberOfImages : 1 == 1)) {
                if ($entry != '.' && $entry != '..' && plgContentartsexylightbox::isImage($path . $entry)) {
                    $title = '';
                    if (isset($descriptionArray[$entry])) {
                        $title = $descriptionArray[$entry];
                    }
                    $imagesCode .= "<a href='" . JURI::root() . "{$path}/{$entry}' rel='sexylightbox[" . $id . "]' class='artsexylightboxpreview' ";
                    if ($title) {
                        $imagesCode .= " title='" . $title . "'";
                    }
                    $imagesCode .= "><img class='artsexylightbox' ";
                    if ($singleImage || $thumbnailPreviewCount || $singleText) {
                        $imagesCode .= " style='display:none;'";
                    }
                    $imagesCode .= " src='";
                    $imagePath = JPATH_SITE . DS . $path . DS . $entry;
                    if ($thumbs && isset($thumbs[$entry])) {
                        $imagesCode .= JURI::root() . "{$thumbnailPath}/{$entry}' ";
                    } else {
                        if (@is_readable($imagePath) && ($previewWidth > 0 || $previewHeight > 0) && isset($autoGenerateThumbs) && $autoGenerateThumbs != 'false') {
                            if (!plgContentartsexylightbox::isExtensionsLoaded()) {
                                plgContentartsexylightbox::loadExtensions();
                            }
                            if (!plgContentartsexylightbox::isExtensionsLoaded()) {
                                $imagesCode .= JURI::root() . "{$path}/{$entry}' ";
                            } else {
                                $imagePathInfo = pathinfo($imagePath);
                                $generatedThumbName = sprintf('%s_%s_%s.%s', md5('artsexythumb_' . $imagePath), $previewWidth, $previewHeight, $imagePathInfo['extension']);
                                if (!file_exists(JPATH_SITE . DS . 'images' . DS . 'artsexylightbox_tmp')) {
                                    mkdir(JPATH_SITE . DS . 'images' . DS . 'artsexylightbox_tmp');
                                }
                                $thumbPath = JPATH_SITE . DS . 'images' . DS . 'artsexylightbox_tmp' . DS . $generatedThumbName;
                                if (!@file_exists($thumbPath)) {
                                    $img = asido::image($imagePath, $thumbPath);
                                    if (!$previewWidth) {
                                        Asido::height($img, $previewHeight);
                                    } else {
                                        if (!$previewHeight) {
                                            Asido::width($img, $previewWidth);
                                        } else {
                                            Asido::resize($img, $previewWidth, $previewHeight, ASIDO_RESIZE_STRETCH);
                                        }
                                    }
                                    $img->save(ASIDO_OVERWRITE_ENABLED);
                                }
                                $imagesCode .= JURI::root() . "images/artsexylightbox_tmp/{$generatedThumbName}' ";
                            }
                        } else {
                            $imagesCode .= JURI::root() . "{$path}/{$entry}' ";
                        }
                    }
                    if ($previewHeight) {
                        $imagesCode .= " height='{$previewHeight}' ";
                    }
                    if ($previewWidth) {
                        $imagesCode .= "width='{$previewWidth}' ";
                    }
                    $imagesCode .= "/></a>";
                }
                $imagesCount++;
            }
            if (isset($popup) && $popup == 'false') {
                return $imagesCode;
            }
            return $imagesCode . $jsCode;
        } else {
            if ($flickr) {
                $flickrApiKey = $finalParams['flickrApiKey'];
                $flickrSet = $finalParams['flickrSet'];
                $flickrThumbSize = $finalParams['flickrThumbSize'];
                if (!isset($flickrThumbSize)) {
                    $flickrThumbSize = "s";
                }
                $flickrImageSize = $finalParams['flickrImageSize'];
                if (!isset($flickrImageSize)) {
                    $flickrImageSize = "m";
                }
                $id = uniqid('artgallery_', false);
                if (isset($flickrApiKey) && isset($flickrSet)) {
                    $imagesCode .= "<div id='{$id}' class='artflickrgallery'></div>";
                    $jsCode .= 'jQuery(document).ready(function(){jQuery("#' . $id . '").flickr({find: "' . $id . '", thumb_size:"' . $flickrThumbSize . '",size:"' . $flickrImageSize . '",per_page:' . $flickrNumberOfImages . ',api_key:"' . $flickrApiKey . '",photoset_id:"' . $flickrSet . '", user_id: "' . $flickr . '", type: "photoset",
				callback: function(el) {SexyLightbox.initialize(' . $dFP . ')}
				})})</script>';
                } else {
                    $flickrLargeImages = $finalParams['flickrLargeImages'];
                    $flickrSmallThumbs = $finalParams['flickrSmallThumbs'];
                    $jsCode .= 'if (!window.sexylightboxEnabled) {jQuery(document).ready(function(){SexyLightbox.initialize(' . $dFP . ')});} if (!window.sexylightboxEnabled) {window.sexylightboxEnabled = true;}</script>';
                    if (strstr($flickr, ',')) {
                        $ids = explode(',', $flickr);
                    } else {
                        $id = $flickr;
                    }
                    if ($id) {
                        $url = 'http://api.flickr.com/services/feeds/photos_public.gne?format=php_serial&id=' . $id;
                    } else {
                        $url = 'http://api.flickr.com/services/feeds/photos_public.gne?format=php_serial&ids=' . $ids;
                    }
                    if ($fp = fopen($url, 'r')) {
                        $content = '';
                        while ($line = fread($fp, 1024)) {
                            $content .= $line;
                        }
                        $rsp_obj = unserialize($content);
                        $i = 1;
                        foreach ($rsp_obj['items'] as $image) {
                            if ($i > $flickrNumberOfImages) {
                                break;
                            }
                            $title = $image['title'];
                            $largeImagePath = $image['m_url'];
                            $smallThumbPath = $image['m_url'];
                            if ($flickrLargeImages) {
                                $largeImagePath = $image['l_url'];
                            }
                            if ($flickrSmallThumbs) {
                                $smallThumbPath = $image['t_url'];
                            }
                            $imagesCode .= "<a href='" . $largeImagePath . "' rel='sexylightbox[" . $id . "]' class='artsexylightboxpreview' ";
                            if ($title) {
                                $imagesCode .= "title='" . $title . "'";
                            }
                            $imagesCode .= "><img class='artsexylightbox' src='" . $smallThumbPath . "'";
                            if ($previewHeight) {
                                $imagesCode .= " height='{$previewHeight}' ";
                            }
                            if ($previewWidth) {
                                $imagesCode .= "width='{$previewWidth}' ";
                            }
                            $imagesCode .= "/></a>";
                            $i++;
                        }
                    }
                }
                if (isset($popup) && $popup == 'false') {
                    return $imagesCode;
                }
                return $imagesCode . $jsCode;
            } else {
                if (isset($content) && !empty($content)) {
                    $theme = $finalParams['theme'];
                    $width = $finalParams['width'];
                    $height = $finalParams['height'];
                    $background = $finalParams['background'];
                    $modal = $finalParams['modal'];
                    $text = $finalParams['text'];
                    $title = $finalParams['title'];
                    $hideContent = $finalParams['hideContent'];
                    $id = uniqid('artinline_', false);
                    $url = "#TB_inline?inlineId={$id}";
                    if (!$height) {
                        $height = "100";
                    }
                    if (!$width) {
                        $width = "300";
                    }
                    if (isset($height) && !empty($height)) {
                        $url .= "&height={$height}";
                    }
                    if (isset($width) && !empty($width)) {
                        $url .= "&width={$width}";
                    }
                    if (isset($modal) && !empty($modal)) {
                        $url .= "&modal={$modal}";
                    }
                    $inlineCode = "<span id='{$id}'>{$content}</span><a href='{$url}' rel='sexylightbox' title='{$title}'>{$text}</a>";
                    $jsCode .= 'jQuery(document).ready(function(){SexyLightbox.initialize(' . $dFP . ');';
                    if ($hideContent) {
                        $jsCode .= 'document.getElementById("' . $id . '").style.display = "none";';
                    }
                    $jsCode .= '}); if (!window.sexylightboxEnabled) {window.sexylightboxEnabled = true;}</script>';
                    return $jsCode . $inlineCode;
                } else {
                    $jsCode .= 'if (!window.sexylightboxEnabled) {jQuery(document).ready(function(){SexyLightbox.initialize(' . $dFP . ')});} if (!window.sexylightboxEnabled) {window.sexylightboxEnabled = true;}</script>';
                    return $jsCode;
                }
            }
        }
    }
示例#6
0
* Resize Example #03
*
* This example shows how to do `stretching` resize
*
* @filesource
* @package Asido.Examples
* @subpackage Asido.Examples.Resize
*/
/////////////////////////////////////////////////////////////////////////////
/**
* Include the main Asido class
*/
include './../../class.asido.php';
/**
* Set the correct driver: this depends on your local environment
*/
asido::driver('gd');
/**
* Create an Asido_Image object and provide the name of the source
* image, and the name with which you want to save the file
*/
$i1 = asido::image('example.png', 'result_03.png');
/**
* Resize the image by stretching it
*/
Asido::resize($i1, 500, 500, ASIDO_RESIZE_STRETCH);
/**
* Save the result
*/
$i1->save(ASIDO_OVERWRITE_ENABLED);
/////////////////////////////////////////////////////////////////////////////