Skip to content

Commit

Permalink
Concatenate 'px' to $size only if $size is numeric (#63)
Browse files Browse the repository at this point in the history
Non-numeric values of size, eg 'x-large', get passed through without alteration
  • Loading branch information
finanalyst authored and rhukster committed Mar 20, 2019
1 parent 64e5e5f commit b44ec54
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions shortcodes/SizeShortcode.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ public function init()
{
$this->shortcode->getHandlers()->add('size', function(ShortcodeInterface $sc) {
$size = $sc->getParameter('size', $this->getBbCode($sc));
return '<span style="font-size: '.$size.'px;">'.$sc->getContent().'</span>';
if ( is_numeric($size) ) { $size = $size.'px' ; }
return '<span style="font-size: '.$size.';">'.$sc->getContent().'</span>';
});
}
}
}

0 comments on commit b44ec54

Please sign in to comment.