function printIphoneCropProcess($blogid, $filename, $cropSize) { global $serviceURL; $tempFile = null; $imageURL = null; if (stristr($filename, 'http://')) { list($originSrc, $filename, $tempFile) = printIphoneCreateRemoteImage($blogid, $filename); } else { $originSrc = ROOT . "/attach/{$blogid}/{$filename}"; } $thumbnailSrc = ROOT . "/cache/thumbnail/{$blogid}/iphoneThumbnail/th_{$filename}"; if (file_exists($originSrc)) { $imageInfo = getimagesize($originSrc); $objThumbnail = new Utils_Image(); if ($imageInfo[0] > $imageInfo[1]) { list($tempWidth, $tempHeight) = $objThumbnail->calcOptimizedImageSize($imageInfo[0], $imageInfo[1], NULL, $cropSize); } else { list($tempWidth, $tempHeight) = $objThumbnail->calcOptimizedImageSize($imageInfo[0], $imageInfo[1], $cropSize, null); } $objThumbnail->imageFile = $originSrc; if ($objThumbnail->resample($tempWidth, $tempHeight) && $objThumbnail->cropRectBySize($cropSize, $cropSize)) { $imageURL = "{$serviceURL}/thumbnail/{$blogid}/iphoneThumbnail/th_{$filename}"; $objThumbnail->saveAsFile($thumbnailSrc); } unset($objThumbnail); if ($tempFile) { unlink($originSrc); } } else { $imageURL = null; } return $imageURL; }
function getEntryContentView($blogid, $id, $content, $formatter, $keywords = array(), $type = 'Post', $useAbsolutePath = true, $bRssMode = false) { $context = Model_Context::getInstance(); importlib('model.blog.attachment'); importlib('model.blog.keyword'); importlib('blogskin'); $context = Model_Context::getInstance(); $cacheKey = 'entry-' . $id . '-' . $type . ($bRssMode ? 'format' : 'summarize') . ($useAbsolutePath ? 'absoultePath' : 'relativePath') . $context->getProperty('blog.displaymode', 'desktop'); $cache = pageCache::getInstance(); $cache->reset($cacheKey); if (!defined('__TEXTCUBE_NO_ENTRY_CACHE__') && $cache->load()) { // If cached content exists. $view = $cache->contents; } else { // No cache is found. $content = fireEvent('Format' . $type . 'Content', $content, $id); $func = $bRssMode ? 'summarizeContent' : 'formatContent'; $view = $func($blogid, $id, $content, $formatter, $keywords, $useAbsolutePath); if ($context->getProperty('blog.displaymode', 'desktop') == 'mobile') { $view = stripHTML($view, array('a', 'abbr', 'acronym', 'address', 'b', 'blockquote', 'br', 'caption', 'cite', 'code', 'dd', 'del', 'dfn', 'div', 'dl', 'dt', 'em', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'hr', 'i', 'iframe', 'img', 'ins', 'kbd', 'li', 'ol', 'p', 'pre', 'q', 's', 'samp', 'span', 'strike', 'strong', 'sub', 'sup', 'table', 'tbody', 'td', 'tfoot', 'th', 'thead', 'tr', 'u', 'ul', 'var')); } if (!$useAbsolutePath) { $view = avoidFlashBorder($view); } if (!empty($keywords) && is_array($keywords)) { $view = bindKeywords($keywords, $view); } // image resampling if (Setting::getBlogSettingGlobal('resamplingDefault') == true) { preg_match_all("@<img.+src=['\"](.+)['\"](.*)/?>@Usi", $view, $images, PREG_SET_ORDER); $view = preg_replace("@<img.+src=['\"].+['\"].*/?>@Usi", '[#####_#####_#####_image_#####_#####_#####]', $view); $contentWidth = Utils_Misc::getContentWidth(); if (count($images) > 0) { for ($i = 0; $i < count($images); $i++) { if (strtolower(Utils_Misc::getFileExtension($images[$i][1])) == 'gif') { $view = preg_replace('@\\[#####_#####_#####_image_#####_#####_#####\\]@', $images[$i][0], $view, 1); continue; } $attributes = preg_match('/(style="cursor: pointer;" onclick="open_img\\((.[^"]+)\\); return false;")/si', $images[$i][2], $matches) ? ' ' . $matches[1] : ''; $attributes .= preg_match('/(alt="([^"]*)")/si', $images[$i][2], $matches) ? ' ' . $matches[1] : ' alt="resize"'; $attributes .= preg_match('/(title="([^"]*)")/si', $images[$i][2], $matches) ? $title = ' ' . $matches[1] : ''; $tempFileName = array_pop(explode('/', $images[$i][1])); if (preg_match('/(.+)\\.w(\\d{1,})\\-h(\\d{1,})\\.(.+)/', $tempFileName, $matches)) { $tempFileName = $matches[1] . '.' . $matches[4]; } $newImage = $images[$i][0]; if (file_exists(__TEXTCUBE_ATTACH_DIR__ . "/{$blogid}/{$tempFileName}")) { $tempAttributes = Utils_Misc::getAttributesFromString($images[$i][2]); $tempOriginInfo = getimagesize(__TEXTCUBE_ATTACH_DIR__ . "/{$blogid}/{$tempFileName}"); if (isset($tempAttributes['width']) && $tempOriginInfo[0] > $tempAttributes['width']) { $image = Utils_Image::getInstance(); list($tempImageURL, $tempImageWidth, $tempImageHeight, $tempImageSrc) = $image->getImageResizer($tempFileName, array('width' => $tempAttributes['width'])); $newImage = "<img src=\"{$tempImageURL}\" width=\"{$tempImageWidth}\" height=\"{$tempImageHeight}\"{$attributes}/>"; } } $view = preg_replace('@\\[#####_#####_#####_image_#####_#####_#####\\]@', $newImage, $view, 1); } } } $cache->contents = $view; $cache->update(); } $cache->reset(); $view = fireEvent('View' . $type . 'Content', $view, $id); return $view; }
function FM_TTML_createNewProperty($filename, $imageWidth, $property) { $blogid = getBlogId(); $image = Utils_Image::getInstance(); if (in_array($image->getImageType(__TEXTCUBE_ATTACH_DIR__ . "/{$blogid}/{$filename}"), array('gif', 'png', 'jpg', 'bmp'))) { return $image->resizeImageToContent($property, __TEXTCUBE_ATTACH_DIR__ . "/{$blogid}/{$filename}", $imageWidth); } else { return array($property, false); } }
<?php /// Copyright (c) 2004-2015, Needlworks / Tatter Network Foundation /// All rights reserved. Licensed under the GPL. /// See the GNU General Public License for more details. (/documents/LICENSE, /documents/COPYRIGHT) $IV = array('GET' => array('f' => array('filename'), 'm' => array('string', 'default' => null))); require ROOT . '/library/preprocessor.php'; $imagePath = __TEXTCUBE_ATTACH_DIR__ . "/{$blogid}/{$_GET['f']}"; if ($fp = @fopen($imagePath, 'r')) { if (isset($_GET['m']) && !empty($_GET['m'])) { if (file_exists($imagePath)) { $imageInfo = getimagesize($imagePath); $cropSize = $_GET['m']; $objThumbnail = new Utils_Image(); if ($imageInfo[0] > $imageInfo[1]) { list($tempWidth, $tempHeight) = $objThumbnail->calcOptimizedImageSize($imageInfo[0], $imageInfo[1], NULL, $cropSize); } else { list($tempWidth, $tempHeight) = $objThumbnail->calcOptimizedImageSize($imageInfo[0], $imageInfo[1], $cropSize, null); } $objThumbnail->imageFile = $imagePath; if ($objThumbnail->resample($tempWidth, $tempHeight) && $objThumbnail->cropRectBySize($cropSize, $cropSize)) { $objThumbnail->saveAsCache(); } unset($objThumbnail); } } else { $imageInfo = @getimagesize($imagePath); if (function_exists('gd_info')) { switch ($imageInfo[2]) { case 1: $image = imagecreatefromgif($imagePath);
function MT_Cover_getCropProcess($blogid, $filename, $cropSize) { $context = Model_Context::getInstance(); $tempFile = null; $imageURL = null; if (stristr($filename, 'http://')) { list($originSrc, $filename, $tempFile) = MT_Cover_getCreateRemoteImage($blogid, $filename); } else { $originSrc = __TEXTCUBE_ATTACH_DIR__ . "/{$blogid}/{$filename}"; } $thumbnailSrc = __TEXTCUBE_CACHE_DIR__ . "/thumbnail/{$blogid}/coverPostThumbnail/th_{$filename}"; if (file_exists($originSrc)) { $imageInfo = getimagesize($originSrc); $objThumbnail = new Utils_Image(); if ($imageInfo[0] > $imageInfo[1]) { list($tempWidth, $tempHeight) = $objThumbnail->calcOptimizedImageSize($imageInfo[0], $imageInfo[1], NULL, $cropSize); } else { list($tempWidth, $tempHeight) = $objThumbnail->calcOptimizedImageSize($imageInfo[0], $imageInfo[1], $cropSize, null); } $objThumbnail->imageFile = $originSrc; if ($objThumbnail->resample($tempWidth, $tempHeight) && $objThumbnail->cropRectBySize($cropSize, $cropSize)) { $imageURL = $context->getProperty('uri.service') . "/thumbnail/{$blogid}/coverPostThumbnail/th_{$filename}"; $objThumbnail->saveAsFile($thumbnailSrc); } unset($objThumbnail); if ($tempFile) { unlink($originSrc); } } else { $imageURL = null; } return $imageURL; }