本文整理匯總了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;
}
}