Last active
January 15, 2018 23:47
-
-
Save joelgriffith/254fa5b9c893399110aa49b54f626511 to your computer and use it in GitHub Desktop.
Get site image
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async function getImage(page) { | |
if (document.querySelector('meta[property="og:image"]')) { | |
return document.querySelector('meta[property="og:image"]').content; | |
} | |
if (document.querySelector('[itemprop="image"]')) { | |
return document.querySelector('[itemprop="image"]').text; | |
} | |
// Return null so we can handle it later | |
return null; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment