Created
July 14, 2013 04:42
-
-
Save ralph-tice/5993238 to your computer and use it in GitHub Desktop.
given the context of a tweet on twitter that has a pic.twitter.com image this is how you get the actual url to the picture... or is it ? Do I just suck at filtering?
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
//v1, works, normally .each instead of [0] | |
$($($('a:contains("pic.twitter.com/")')[0]).parent().parent().parent().data('expandedFooter')).children(".cards-media-container").children().children(".media").children("a").data('url') | |
//v2, found 'find' instead of 'filter'... | |
$($($('a:contains("pic.twitter.com/")')[0]).parent().parent().parent().data('expandedFooter')).find("a.media-thumbnail").data('url') |
Seems like you wouldn't need to find pic.twitter.com, and just look for the media thumbnail. Might be able to do that with .filter(). Not sure of the use case or performance constraints.
The media thumbnail exists inside the data attribute for the tweet -- it isn't actually a rendered DOM element, it only gets put into the DOM if you expand the footer.
So this is 'find a tweet that has a link that has pic.twitter.com, then reach up to the tweet container and grab the data attribute, wrap it in a jQuery object, and grab the media thumbnail link there and pull off its data url...' pic.twitter.com images are actually something like https://pbs.twimg.com/media/BPXqF_YCAAA2yqz.jpg:large
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
http://stackoverflow.com/questions/15923116/html-markup-within-the-data-attribute