Skip to content

Instantly share code, notes, and snippets.

@laginha87
Created October 9, 2015 14:00
Show Gist options
  • Save laginha87/d37476d0a37f97f5a365 to your computer and use it in GitHub Desktop.
Save laginha87/d37476d0a37f97f5a365 to your computer and use it in GitHub Desktop.
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