Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce instances where photo is implied #210

Merged
merged 3 commits into from May 22, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion Mf2/Parser.php
Expand Up @@ -1090,7 +1090,7 @@ public function parseH(\DOMElement $e, $is_backcompat = false, $has_nested_mf =
}

// Check for u-photo
if (!array_key_exists('photo', $return) && !$is_backcompat) {
if (!array_key_exists('photo', $return) && !in_array('u-', $prefixes) && !$is_backcompat) {
gRegorLove marked this conversation as resolved.
Show resolved Hide resolved

$photo = $this->parseImpliedPhoto($e);

Expand Down
11 changes: 11 additions & 0 deletions tests/Mf2/ParseImpliedTest.php
Expand Up @@ -375,5 +375,16 @@ public function testNoImgSrcImpliedName() {
$this->assertArrayHasKey('name', $result['items'][0]['properties']);
$this->assertEquals('My Name', $result['items'][0]['properties']['name'][0]);
}

/**
* @see https://github.com/microformats/php-mf2/issues/198
*/
public function testNoImipliedPhoto() {
$input = '<div class="h-card"> <span class="p-org">Organization Name</span> <img src="/logo.png" class="u-logo" alt=""> </div>';
$result = Mf2\parse($input);

$this->assertArrayNotHasKey('photo', $result['items'][0]['properties']);
}

}