Index: trunk/phase3/includes/Linker.php |
— | — | @@ -427,9 +427,20 @@ |
428 | 428 | return $s; |
429 | 429 | } |
430 | 430 | |
431 | | - /** @todo document */ |
| 431 | + /** Creates the HTML source for images |
| 432 | + * @param object $nt |
| 433 | + * @param string $label label text |
| 434 | + * @param string $alt alt text |
| 435 | + * @param string $align horizontal alignment: none, left, center, right) |
| 436 | + * @param array $params some format keywords: width, height, page, upright, upright_factor, frameless, border |
| 437 | + * @param boolean $framed shows image in original size in a frame |
| 438 | + * @param boolean $thumb shows image as thumbnail in a frame |
| 439 | + * @param string $manual_thumb image name for the manual thumbnail |
| 440 | + * @param string $valign vertical alignment: baseline, sub, super, top, text-top, middle, bottom, text-bottom |
| 441 | + * @return string |
| 442 | + */ |
432 | 443 | function makeImageLinkObj( $nt, $label, $alt, $align = '', $params = array(), $framed = false, |
433 | | - $thumb = false, $manual_thumb = '', $valign = '', $upright = false, $upright_factor = 0, $border = false ) |
| 444 | + $thumb = false, $manual_thumb = '', $valign = '' ) |
434 | 445 | { |
435 | 446 | global $wgContLang, $wgUser, $wgThumbLimits, $wgThumbUpright; |
436 | 447 | |
— | — | @@ -448,10 +459,9 @@ |
449 | 460 | $postfix = '</div>'; |
450 | 461 | $align = 'none'; |
451 | 462 | } |
452 | | - |
453 | 463 | if ( !isset( $params['width'] ) ) { |
454 | 464 | $params['width'] = $img->getWidth( $page ); |
455 | | - if( $thumb || $framed ) { |
| 465 | + if( $thumb || $framed || isset( $params['frameless'] ) ) { |
456 | 466 | $wopt = $wgUser->getOption( 'thumbsize' ); |
457 | 467 | |
458 | 468 | if( !isset( $wgThumbLimits[$wopt] ) ) { |
— | — | @@ -459,12 +469,12 @@ |
460 | 470 | } |
461 | 471 | |
462 | 472 | // Reduce width for upright images when parameter 'upright' is used |
463 | | - if ( $upright_factor == 0 ) { |
464 | | - $upright_factor = $wgThumbUpright; |
| 473 | + if ( !isset( $params['upright_factor'] ) || $params['upright_factor'] == 0 ) { |
| 474 | + $params['upright_factor'] = $wgThumbUpright; |
465 | 475 | } |
466 | 476 | // Use width which is smaller: real image width or user preference width |
467 | 477 | // For caching health: If width scaled down due to upright parameter, round to full __0 pixel to avoid the creation of a lot of odd thumbs |
468 | | - $params['width'] = min( $params['width'], $upright ? round( $wgThumbLimits[$wopt] * $upright_factor, -1 ) : $wgThumbLimits[$wopt] ); |
| 478 | + $params['width'] = min( $params['width'], isset( $params['upright'] ) ? round( $wgThumbLimits[$wopt] * $params['upright_factor'], -1 ) : $wgThumbLimits[$wopt] ); |
469 | 479 | } |
470 | 480 | } |
471 | 481 | |
— | — | @@ -480,7 +490,7 @@ |
481 | 491 | if ( $align == '' ) { |
482 | 492 | $align = $wgContLang->isRTL() ? 'left' : 'right'; |
483 | 493 | } |
484 | | - return $prefix.$this->makeThumbLinkObj( $img, $label, $alt, $align, $params, $framed, $manual_thumb, $upright ).$postfix; |
| 494 | + return $prefix.$this->makeThumbLinkObj( $img, $label, $alt, $align, $params, $framed, $manual_thumb ).$postfix; |
485 | 495 | } |
486 | 496 | |
487 | 497 | if ( $params['width'] && $img->exists() ) { |
— | — | @@ -504,7 +514,7 @@ |
505 | 515 | if ( $valign ) { |
506 | 516 | $imgAttribs['style'] = "vertical-align: $valign"; |
507 | 517 | } |
508 | | - if ( $border ) { |
| 518 | + if ( isset( $params['border'] ) ) { |
509 | 519 | $imgAttribs['class'] = "thumbborder"; |
510 | 520 | } |
511 | 521 | $linkAttribs = array( |
— | — | @@ -528,14 +538,14 @@ |
529 | 539 | * Make HTML for a thumbnail including image, border and caption |
530 | 540 | * $img is an Image object |
531 | 541 | */ |
532 | | - function makeThumbLinkObj( $img, $label = '', $alt, $align = 'right', $params = array(), $framed=false , $manual_thumb = "", $upright = false ) { |
| 542 | + function makeThumbLinkObj( $img, $label = '', $alt, $align = 'right', $params = array(), $framed=false , $manual_thumb = "" ) { |
533 | 543 | global $wgStylePath, $wgContLang; |
534 | 544 | |
535 | 545 | $page = isset( $params['page'] ) ? $params['page'] : false; |
536 | 546 | |
537 | 547 | if ( empty( $params['width'] ) ) { |
538 | 548 | // Reduce width for upright images when parameter 'upright' is used |
539 | | - $params['width'] = $upright ? 130 : 180; |
| 549 | + $params['width'] = isset( $params['upright'] ) ? 130 : 180; |
540 | 550 | } |
541 | 551 | $thumb = false; |
542 | 552 | if ( $manual_thumb != '' ) { |
Index: trunk/phase3/includes/Parser.php |
— | — | @@ -4418,6 +4418,7 @@ |
4419 | 4419 | # * ___px scale to ___ pixels width, no aligning. e.g. use in taxobox |
4420 | 4420 | # * center center the image |
4421 | 4421 | # * framed Keep original image size, no magnify-button. |
| 4422 | + # * frameless like 'thumb' but without a frame. Keeps user preferences for width |
4422 | 4423 | # * upright reduce width for upright images, rounded to full __0 px |
4423 | 4424 | # * border draw a 1px border around the image |
4424 | 4425 | # vertical-align values (no % or length right now): |
— | — | @@ -4442,6 +4443,7 @@ |
4443 | 4444 | $mwManualThumb =& MagicWord::get( 'img_manualthumb' ); |
4444 | 4445 | $mwWidth =& MagicWord::get( 'img_width' ); |
4445 | 4446 | $mwFramed =& MagicWord::get( 'img_framed' ); |
| 4447 | + $mwFrameless =& MagicWord::get( 'img_frameless' ); |
4446 | 4448 | $mwUpright =& MagicWord::get( 'img_upright' ); |
4447 | 4449 | $mwBorder =& MagicWord::get( 'img_border' ); |
4448 | 4450 | $mwPage =& MagicWord::get( 'img_page' ); |
— | — | @@ -4449,9 +4451,6 @@ |
4450 | 4452 | |
4451 | 4453 | $params = array(); |
4452 | 4454 | $framed = $thumb = false; |
4453 | | - $upright = false; |
4454 | | - $upright_factor = 0; |
4455 | | - $border = false; |
4456 | 4455 | $manual_thumb = '' ; |
4457 | 4456 | $align = $valign = ''; |
4458 | 4457 | $sk = $this->mOptions->getSkin(); |
— | — | @@ -4460,10 +4459,12 @@ |
4461 | 4460 | if ( !is_null( $mwThumb->matchVariableStartToEnd($val) ) ) { |
4462 | 4461 | $thumb=true; |
4463 | 4462 | } elseif ( !is_null( $match = $mwUpright->matchVariableStartToEnd( $val ) ) ) { |
4464 | | - $upright = true; |
4465 | | - $upright_factor = floatval( $match ); |
| 4463 | + $params['upright'] = true; |
| 4464 | + $params['upright_factor'] = floatval( $match ); |
| 4465 | + } elseif ( !is_null( $match = $mwFrameless->matchVariableStartToEnd( $val ) ) ) { |
| 4466 | + $params['frameless'] = true; |
4466 | 4467 | } elseif ( !is_null( $mwBorder->matchVariableStartToEnd( $val ) ) ) { |
4467 | | - $border = true; |
| 4468 | + $params['border'] = true; |
4468 | 4469 | } elseif ( ! is_null( $match = $mwManualThumb->matchVariableStartToEnd($val) ) ) { |
4469 | 4470 | # use manually specified thumbnail |
4470 | 4471 | $thumb=true; |
— | — | @@ -4510,7 +4511,7 @@ |
4511 | 4512 | $alt = Sanitizer::stripAllTags( $alt ); |
4512 | 4513 | |
4513 | 4514 | # Linker does the rest |
4514 | | - return $sk->makeImageLinkObj( $nt, $caption, $alt, $align, $params, $framed, $thumb, $manual_thumb, $valign, $upright, $upright_factor, $border ); |
| 4515 | + return $sk->makeImageLinkObj( $nt, $caption, $alt, $align, $params, $framed, $thumb, $manual_thumb, $valign ); |
4515 | 4516 | } |
4516 | 4517 | |
4517 | 4518 | /** |
Index: trunk/phase3/languages/messages/MessagesEn.php |
— | — | @@ -281,6 +281,7 @@ |
282 | 282 | 'img_width' => array( 1, '$1px' ), |
283 | 283 | 'img_center' => array( 1, 'center', 'centre' ), |
284 | 284 | 'img_framed' => array( 1, 'framed', 'enframed', 'frame' ), |
| 285 | + 'img_frameless' => array( 1, 'frameless' ), |
285 | 286 | 'img_page' => array( 1, 'page=$1', 'page $1' ), |
286 | 287 | 'img_upright' => array( 1, 'upright', 'upright=$1', 'upright $1' ), |
287 | 288 | 'img_border' => array( 1, 'border' ), |
Index: trunk/phase3/RELEASE-NOTES |
— | — | @@ -34,13 +34,15 @@ |
35 | 35 | * (bug 9628) Show warnings about slave lag on Special:Contributions, |
36 | 36 | Special:Watchlist |
37 | 37 | * (bug 8818) Expose "wpDestFile" as parameter $1 to "uploaddisabledtext" |
38 | | -* Introducing new image parameter 'upright' and corresponding variable |
| 38 | +* Introducing new image keyword 'upright' and corresponding variable |
39 | 39 | $wgThumbUpright. This allows better proportional view of upright images |
40 | 40 | related to landscape images on a page without nailing the width of upright |
41 | 41 | images to a fix value which makes views for anon unproportional and user |
42 | 42 | preferences useless |
43 | | -* (bug 6072) Add a 'border' keyword to the image syntax |
44 | | - |
| 43 | +* (bug 6072) Introducing 'border' keyword to the [[Image:]] syntax |
| 44 | +* Introducing 'frameless' keyword to [[Image:]] syntax which respects the |
| 45 | + user preferences for image width like 'thumb' but without a frame. |
| 46 | + |
45 | 47 | == Bugfixes since 1.10 == |
46 | 48 | |
47 | 49 | * (bug 9712) Use Arabic comma in date/time formats for Arabic and Farsi |