本文整理汇总了PHP中ImageHelper::heightPreference方法的典型用法代码示例。如果您正苦于以下问题:PHP ImageHelper::heightPreference方法的具体用法?PHP ImageHelper::heightPreference怎么用?PHP ImageHelper::heightPreference使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ImageHelper
的用法示例。
在下文中一共展示了ImageHelper::heightPreference方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getRelatedImagesWidget
function getRelatedImagesWidget($title)
{
global $wgUser;
$exceptions = wfMsg('ih_exceptions');
$imageExceptions = split("\n", $exceptions);
$articles = ImageHelper::getLinkedArticles($title);
$images = array();
foreach ($articles as $t) {
$results = ImageHelper::getImages($t->getArticleID());
if (count($results) <= 1) {
continue;
}
$titleDb = $title->getDBkey();
foreach ($results as $row) {
if ($row['il_to'] != $titleDb && !in_array($row['il_to'], $imageExceptions)) {
$images[] = $row['il_to'];
}
}
}
$count = 0;
$maxLoc = count($images);
$maxImages = $maxLoc;
$finalImages = array();
while ($count < 6 && $count < $maxImages) {
$loc = rand(0, $maxLoc);
if ($images[$loc] != null) {
$image = Title::newFromText("Image:" . $images[$loc]);
if ($image && $image->getArticleID() > 0) {
$file = wfFindFile($image);
if ($file && isset($file)) {
$finalImages[] = array('title' => $image, 'file' => $file);
$images[$loc] = null;
$count++;
} else {
$maxImages--;
}
} else {
$maxImages--;
}
$images[$loc] = null;
}
}
if (count($finalImages) > 0) {
$html = '<div><h3>' . wfMsg('ih_relatedimages_widget') . '</h3><table style="margin-top:10px" class="image_siderelated">';
$count = 0;
foreach ($finalImages as $imageObject) {
$image = $imageObject['title'];
$file = $imageObject['file'];
if ($count % 2 == 0) {
$html .= "<tr>";
}
$heightPreference = ImageHelper::heightPreference(127, 140, $file);
$thumb = $file->getThumbnail(127, 140, true, true, $heightPreference);
$imageUrl = $image->getFullURL();
$thumbUrl = $thumb->url;
$imageTitle = $imageName;
$html .= "<td valign='top'>\n\t\t\t\t\t\t\t<a href='" . $imageUrl . "' title='" . $imageTitle . "' class='image'>\n\t\t\t\t\t\t\t<img border='0' class='mwimage101' src='" . wfGetPad($thumbUrl) . "' alt='" . $imageTitle . "'>\n\t\t\t\t\t\t\t</a>\n\t\t\t\t\t\t</td>";
if ($count % 2 == 2) {
$html .= "</tr>";
}
$count++;
}
if ($count % 3 != 2) {
$html .= "</tr>";
}
$html .= "</table></div>";
return $html;
}
}