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

✨ amp-addthis: Adding Open Graph image meta tag as fallback for media prop #22697

Conversation

matthinegardner
Copy link
Contributor

Description:

For the Pinterest share buttons, AddThis passes a media value to know which image to share. Currently, the image is only passed if the component has the data-media attribute.

This feature will use the first Open Graph image meta tag (og:image) on the page as a fallback, in case the data-media attribute is not present.

@aghassemi aghassemi self-requested a review June 18, 2019 17:05
@@ -31,3 +31,15 @@ export const getDetailsForMeta = meta => {
content,
};
};

export const getOgImage = doc => {
const ogImages = doc.head.querySelectorAll('meta[property="og:image"]');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since you only care about the first one, please use querySelector instead of querySelectorAll

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @aghassemi. I just added a new commit that uses querySelector instead.

@aghassemi aghassemi merged commit 9b6c71f into ampproject:master Jun 19, 2019
@matthinegardner matthinegardner deleted the matthinegardner/Obtain-OG-image-for-media-property branch June 19, 2019 20:42
thekorn pushed a commit to edelight/amphtml that referenced this pull request Sep 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants