Created
October 9, 2015 14:00
-
-
Save laginha87/d37476d0a37f97f5a365 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
IMG_EXTENSION_REGEX = /(-(\d+)x(\d+))?\.(\w*)$/ | |
PREFERED_IMAGE_SIZE_WITH_CAPTURED_EXTENSION = '-300x160.\+' | |
def extract_image(html) | |
img_src = Nokogiri::HTML(e.content).css("img").first.attributes['src'].value | |
img_src.sub(IMG_EXTENSION_REGEX, PREFERED_IMAGE_SIZE_WITH_CAPTURED_EXTENSION) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment