Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3435
8535a.patch
Public
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Authored By
•
bzimport
Nov 21 2014, 9:29 PM
2014-11-21 21:29:30 (UTC+0)
Size
7 KB
Referenced Files
None
Subscribers
None
8535a.patch
View Options
Index: includes/Linker.php
===================================================================
--- includes/Linker.php (revision 19138)
+++ includes/Linker.php (working copy)
@@ -432,7 +432,7 @@
/** @todo document */
function makeImageLinkObj( $nt, $label, $alt, $align = '', $width = false, $height = false, $framed = false,
- $thumb = false, $manual_thumb = '', $page = null )
+ $thumb = false, $manual_thumb = '', $page = null, $valign = '' )
{
global $wgContLang, $wgUser, $wgThumbLimits, $wgGenerateThumbnailOnParse;
@@ -533,6 +533,9 @@
( $width
? ( 'width="'.$width.'" height="'.$height.'" ' )
: '' ) .
+ ( $valign
+ ? ( 'style="vertical-align: '.$valign.'" ' )
+ : '' ) .
'longdesc="'.$u.'" /></a>';
}
if ( '' != $align ) {
Index: includes/Parser.php
===================================================================
--- includes/Parser.php (revision 19138)
+++ includes/Parser.php (working copy)
@@ -4361,8 +4361,6 @@
function makeImage( $nt, $options ) {
global $wgUseImageResize, $wgDjvuRenderer;
- $align = '';
-
# Check if the options text is of the form "options|alt text"
# Options are:
# * thumbnail make a thumbnail with enlarge-icon and caption, alignment depends on lang
@@ -4372,62 +4370,76 @@
# * ___px scale to ___ pixels width, no aligning. e.g. use in taxobox
# * center center the image
# * framed Keep original image size, no magnify-button.
+ # vertical-align values (no % or length right now):
+ # * baseline
+ # * sub
+ # * super
+ # * top
+ # * text-top
+ # * middle
+ # * bottom
+ # * text-bottom
$part = explode( '|', $options);
- $mwThumb =& MagicWord::get( 'img_thumbnail' );
+ $mwAlign = array();
+ $alignments = array( 'left', 'right', 'center', 'none', 'baseline', 'sub', 'super', 'top', 'text-top', 'middle', 'bottom', 'text-bottom' );
+ foreach ( $alignments as $alignment ) {
+ $mwAlign[$alignment] =& MagicWord::get( 'img_'.$alignment );
+ }
+ $mwThumb =& MagicWord::get( 'img_thumbnail' );
$mwManualThumb =& MagicWord::get( 'img_manualthumb' );
- $mwLeft =& MagicWord::get( 'img_left' );
- $mwRight =& MagicWord::get( 'img_right' );
- $mwNone =& MagicWord::get( 'img_none' );
- $mwWidth =& MagicWord::get( 'img_width' );
- $mwCenter =& MagicWord::get( 'img_center' );
- $mwFramed =& MagicWord::get( 'img_framed' );
- $mwPage =& MagicWord::get( 'img_page' );
+ $mwWidth =& MagicWord::get( 'img_width' );
+ $mwFramed =& MagicWord::get( 'img_framed' );
+ $mwPage =& MagicWord::get( 'img_page' );
$caption = '';
$width = $height = $framed = $thumb = false;
$page = null;
$manual_thumb = '' ;
+ $align = $valign = '';
foreach( $part as $val ) {
- if ( $wgUseImageResize && ! is_null( $mwThumb->matchVariableStartToEnd($val) ) ) {
- $thumb=true;
- } elseif ( ! is_null( $match = $mwManualThumb->matchVariableStartToEnd($val) ) ) {
- # use manually specified thumbnail
- $thumb=true;
- $manual_thumb = $match;
- } elseif ( ! is_null( $mwRight->matchVariableStartToEnd($val) ) ) {
- # remember to set an alignment, don't render immediately
- $align = 'right';
- } elseif ( ! is_null( $mwLeft->matchVariableStartToEnd($val) ) ) {
- # remember to set an alignment, don't render immediately
- $align = 'left';
- } elseif ( ! is_null( $mwCenter->matchVariableStartToEnd($val) ) ) {
- # remember to set an alignment, don't render immediately
- $align = 'center';
- } elseif ( ! is_null( $mwNone->matchVariableStartToEnd($val) ) ) {
- # remember to set an alignment, don't render immediately
- $align = 'none';
- } elseif ( isset( $wgDjvuRenderer ) && $wgDjvuRenderer
- && ! is_null( $match = $mwPage->matchVariableStartToEnd($val) ) ) {
- # Select a page in a multipage document
- $page = $match;
- } elseif ( $wgUseImageResize && !$width && ! is_null( $match = $mwWidth->matchVariableStartToEnd($val) ) ) {
- wfDebug( "img_width match: $match\n" );
- # $match is the image width in pixels
- $m = array();
- if ( preg_match( '/^([0-9]*)x([0-9]*)$/', $match, $m ) ) {
- $width = intval( $m[1] );
- $height = intval( $m[2] );
+ do {
+ if ( $wgUseImageResize && ! is_null( $mwThumb->matchVariableStartToEnd($val) ) ) {
+ $thumb=true;
+ } elseif ( ! is_null( $match = $mwManualThumb->matchVariableStartToEnd($val) ) ) {
+ # use manually specified thumbnail
+ $thumb=true;
+ $manual_thumb = $match;
} else {
- $width = intval($match);
+ foreach( $alignments as $alignment ) {
+ if ( ! is_null( $mwAlign[$alignment]->matchVariableStartToEnd($val) ) ) {
+ switch ( $alignment ) {
+ case 'left': case 'right': case 'center': case 'none':
+ $align = $alignment; break;
+ default:
+ $valign = $alignment;
+ }
+ break 2;
+ }
+ }
+ if ( isset( $wgDjvuRenderer ) && $wgDjvuRenderer
+ && ! is_null( $match = $mwPage->matchVariableStartToEnd($val) ) ) {
+ # Select a page in a multipage document
+ $page = $match;
+ } elseif ( $wgUseImageResize && !$width && ! is_null( $match = $mwWidth->matchVariableStartToEnd($val) ) ) {
+ wfDebug( "img_width match: $match\n" );
+ # $match is the image width in pixels
+ $m = array();
+ if ( preg_match( '/^([0-9]*)x([0-9]*)$/', $match, $m ) ) {
+ $width = intval( $m[1] );
+ $height = intval( $m[2] );
+ } else {
+ $width = intval($match);
+ }
+ } elseif ( ! is_null( $mwFramed->matchVariableStartToEnd($val) ) ) {
+ $framed=true;
+ } else {
+ $caption = $val;
+ }
}
- } elseif ( ! is_null( $mwFramed->matchVariableStartToEnd($val) ) ) {
- $framed=true;
- } else {
- $caption = $val;
- }
+ } while ( false );
}
# Strip bad stuff out of the alt text
$alt = $this->replaceLinkHoldersText( $caption );
@@ -4440,7 +4452,7 @@
# Linker does the rest
$sk =& $this->mOptions->getSkin();
- return $sk->makeImageLinkObj( $nt, $caption, $alt, $align, $width, $height, $framed, $thumb, $manual_thumb, $page );
+ return $sk->makeImageLinkObj( $nt, $caption, $alt, $align, $width, $height, $framed, $thumb, $manual_thumb, $page, $valign );
}
/**
Index: languages/messages/MessagesEn.php
===================================================================
--- languages/messages/MessagesEn.php (revision 19138)
+++ languages/messages/MessagesEn.php (working copy)
@@ -289,6 +289,14 @@
'img_center' => array( 1, 'center', 'centre' ),
'img_framed' => array( 1, 'framed', 'enframed', 'frame' ),
'img_page' => array( 1, 'page=$1', 'page $1' ),
+ 'img_baseline' => array( 1, 'baseline' ),
+ 'img_sub' => array( 1, 'sub' ),
+ 'img_super' => array( 1, 'super', 'sup' ),
+ 'img_top' => array( 1, 'top' ),
+ 'img_text-top' => array( 1, 'text-top' ),
+ 'img_middle' => array( 1, 'middle' ),
+ 'img_bottom' => array( 1, 'bottom' ),
+ 'img_text-bottom' => array( 1, 'text-bottom' ),
'int' => array( 0, 'INT:' ),
'sitename' => array( 1, 'SITENAME' ),
'ns' => array( 0, 'NS:' ),
File Metadata
Details
Attached
Mime Type
text/x-diff
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3003
Default Alt Text
8535a.patch (7 KB)
Attached To
Mode
T10535: Expose additional image alignment attributes in wiki text
Attached
Detach File
Event Timeline
Log In to Comment