Skip to content

Commit

Permalink
Added center and auto alignment options.
Browse files Browse the repository at this point in the history
  • Loading branch information
Andreas Jonsson committed Oct 19, 2012
1 parent 276da52 commit f3fa1e4
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions EmbedVideo.hooks.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public static function parserFunction_ev($parser, $service = null, $id = null, $
}
$height = self::getHeight($entry, $width);

$hasalign = ($align !== null);
$hasalign = ($align !== null || $align == 'auto');

if ($hasalign) {
$align = trim($align);
Expand Down Expand Up @@ -173,7 +173,8 @@ private static function generateNormalClause($url, $width, $height) {
*/
private static function generateAlignExternClause($clause, $align, $desc, $width, $height)
{
$clause = "<div class=\"thumb t{$align}\">" .
$alignClass = self::getAlignmentClass($align);
$clause = "<div class=\"thumb {$alignClass}\">" .
"<div class=\"thumbinner\" style=\"width: {$width}px;\">" .
$clause .
"<div class=\"thumbcaption\">" .
Expand All @@ -195,7 +196,8 @@ private static function generateAlignExternClause($clause, $align, $desc, $width
* @return string
*/
private static function generateAlignClause($url, $width, $height, $align, $desc) {
$clause = "<div class=\"thumb t{$align}\">" .
$alignClass = self::getAlignmentClass($align);
$clause = "<div class=\"thumb {$alignClass}\">" .
"<div class=\"thumbinner\" style=\"width: {$width}px;\">" .
"<object width=\"{$width}\" height=\"{$height}\">" .
"<param name=\"movie\" value=\"{$url}\"></param>" .
Expand Down Expand Up @@ -258,7 +260,15 @@ private static function sanitizeWidth($entry, &$width) {
* @return {\code true} if the align parameter is valid, otherwise {\code false}.
*/
private static function validateAlignment($align) {
return ($align == 'left' || $align == 'right');
return ($align == 'left' || $align == 'right' || $align == 'center' || $align == 'auto');
}

private static function getAlignmentClass($align) {
if ( $align == 'left' || $align == 'right' ) {
return 't' . $align;
}

return $align;
}

/**
Expand Down

0 comments on commit f3fa1e4

Please sign in to comment.