Commit 71a35354 authored by Aaron Parecki's avatar Aaron Parecki Committed by GitHub

Merge pull request #120 from aaronpk/issue-114

parse poster attribute for video tags
parents 26e4ed43 9fb3c217
......@@ -615,6 +615,8 @@ class Parser {
$uValue = $u->getAttribute('href');
} elseif (in_array($u->tagName, array('img', 'audio', 'video', 'source')) and $u->hasAttribute('src')) {
$uValue = $u->getAttribute('src');
} elseif ($u->tagName == 'video' and !$u->hasAttribute('src') and $u->hasAttribute('poster')) {
$uValue = $u->getAttribute('poster');
} elseif ($u->tagName == 'object' and $u->hasAttribute('data')) {
$uValue = $u->getAttribute('data');
}
......
......@@ -222,6 +222,19 @@ class ParseUTest extends PHPUnit_Framework_TestCase {
$this->assertEquals('http://example.com/video.ogg', $output['items'][0]['properties']['video'][1]);
}
/**
* @group parseU
*/
public function testParseUHandlesVideoPoster() {
$input = '<div class="h-entry"><video class="u-photo" poster="http://example.com/posterimage.jpg"><source class="u-video" src="http://example.com/video.mp4" type="video/mp4"></video></div>';
$parser = new Parser($input);
$output = $parser->parse();
$this->assertArrayHasKey('video', $output['items'][0]['properties']);
$this->assertEquals('http://example.com/video.mp4', $output['items'][0]['properties']['video'][0]);
$this->assertEquals('http://example.com/posterimage.jpg', $output['items'][0]['properties']['photo'][0]);
}
/**
* @group parseU
*/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment