本文整理汇总了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;
}
示例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);