当前位置: 首页>>代码示例>>PHP>>正文


PHP LocalFile::getThumbnail方法代码示例

本文整理汇总了PHP中LocalFile::getThumbnail方法的典型用法代码示例。如果您正苦于以下问题:PHP LocalFile::getThumbnail方法的具体用法?PHP LocalFile::getThumbnail怎么用?PHP LocalFile::getThumbnail使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在LocalFile的用法示例。


在下文中一共展示了LocalFile::getThumbnail方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: insertImage

 protected function insertImage($name, $mwname, $result)
 {
     global $wgRequest, $wgImageMagickConvertCommand, $wgServer;
     if (!$result) {
         $result = array();
     } elseif ($result['error']) {
         return $result;
     }
     $fromPage = $wgRequest->getVal('viapage');
     if (!empty($mwname) && !empty($name)) {
         $name = trim(urldecode($name));
         $dateTime = new DateTime();
         $mwDate = wfTimestamp(TS_MW);
         // Mediawiki timestamp: 'YmdHis'
         list($first, $ext) = self::splitFilenameExt($name);
         $ext = strtolower($ext);
         $validExts = array('GIF', 'JPG', 'JPEG', 'PNG');
         if (!in_array(strtoupper($ext), $validExts)) {
             $result['error'] = 'Error: Invalid file extension ' . strtoupper($ext) . '. Valid extensions are:';
             foreach ($validExts as $validExt) {
                 $result['error'] .= ' ' . strtoupper($validExt);
             }
             $result['error'] .= '.';
             return $result;
         }
         $saveName = false;
         $titleExists = false;
         $suffixNum = 1;
         while (!$saveName || $titleExists) {
             $saveName = 'User Completed Image ' . $fromPage . ' ' . $dateTime->format('Y.m.d H.i.s') . ' ' . $suffixNum . '.' . $ext;
             $title = Title::makeTitleSafe(NS_IMAGE, $saveName);
             $newFile = true;
             $titleExists = $title->exists();
             $suffixNum++;
         }
         $temp_file = new TempLocalImageFile(Title::newFromText($mwname, NS_IMAGE), RepoGroup::singleton()->getLocalRepo());
         if (!$temp_file || !$temp_file->exists()) {
             $result['error'] = 'Error: A server error has occurred. Please try again.';
             return $result;
         }
         // Image orientation is a bit wonky on some mobile devices; use ImageMagick's auto-orient to try fixing it.
         $tempFilePath = $temp_file->getPath();
         $cmd = $wgImageMagickConvertCommand . ' ' . $tempFilePath . ' -auto-orient ' . $tempFilePath;
         exec($cmd);
         // Use a CC license
         $comment = '{{Self}}';
         $file = new LocalFile($title, RepoGroup::singleton()->getLocalRepo());
         $file->upload($tempFilePath, $comment, $comment);
         if (!$file || !$file->exists()) {
             $result['error'] = 'Error: A server error has occurred. Please try again.';
             return $result;
         }
         $temp_file->delete('');
         $fileTitle = $file->getTitle();
         $fileURL = $file->url;
         $thumbURL = '';
         $thumb = $file->getThumbnail(200, -1, true, true);
         if (!$thumb) {
             $result['error'] = 'Error: A server error has occurred. Please try again.';
             $file->delete('');
             return $result;
         }
         $thumbURL = $thumb->url;
         $result['titleText'] = $fileTitle->getText();
         $result['titleDBkey'] = substr($fileTitle->getDBkey(), 21);
         // Only keep important info
         $result['titlePreText'] = '/' . $fileTitle->getPrefixedText();
         $result['titleArtID'] = $fileTitle->getArticleID();
         $result['timestamp'] = $mwDate;
         $result['fromPage'] = $wgRequest->getVal('viapage');
         $result['thumbURL'] = $thumbURL;
         $result['fileURL'] = $wgServer . $fileURL;
     }
     return $result;
 }
开发者ID:ErdemA,项目名称:wikihow,代码行数:75,代码来源:ImageUploadHandler.class.php

示例2: htmlspecialchars

</h2>
		</td>
	</tr>
	<tr id="ImageUploadCompare">
		<td>
			<?php 
echo $file_temp->getThumbnail(265, 205)->toHtml();
?>
		</td>
		<td>
			<input type="hidden" name="ImageUploadExistingName" value="<?php 
echo htmlspecialchars($file_existing->getName());
?>
" />
			<?php 
echo $file_existing->getThumbnail(265, 205)->toHtml();
?>
		</td>
	</tr>
	<tr>
		<td>
			<input type="text" name="ImageUploadRenameName" value="<?php 
echo htmlspecialchars($suggestedFirstPart);
?>
" />
			<label for="ImageUploadRenameName">.<?php 
echo htmlspecialchars($extension);
?>
</label><br />
	        <input name="ImageUploadRenameExtension" type="hidden" value="<?php 
echo htmlspecialchars($extension);
开发者ID:ErdemA,项目名称:wikihow,代码行数:31,代码来源:eiu_conflict.tmpl.php


注:本文中的LocalFile::getThumbnail方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。