def sexy_image(term, opts = {:width => 100, :height => 100})

      # The loving is a mess, what happened to all of the feeling?
      # I thought it was for real; babies, rings and fools kneeling
      # And words of pledging trust and lifetimes stretching forever
      # So what went wrong? It was a lie, it crumbled apart
      # Ghost figures of past, present, future haunting the heart
      sexy_image = term.is_a?(SexItUp::SexItUpImage) ? term : SexItUpImage.where(['image_search_term = ?', term]).random

      if sexy_image.nil? || sexy_image.blank?
        puts "No image found.  Searching for #{term}."
        # No image object passed in or found; let's go search.

        sexy_image = SexItUpImage.find_all(term).random
      end

      unless sexy_image.nil?
        style           = "#{opts[:width]}x#{opts[:height]}"
        style_sym       = "s_#{style}".to_sym
        style_hash      = {style_sym => [style]}

        sexy_image.set_attachment_sizes(style_hash)
        sexy_image.image.reprocess! unless File.exist?(sexy_image.image.path(style_sym)) # No need for reprocessing if size already exists

        tag = "<img"
        tag += " class=\"#{opts[:class]}\"" if opts[:class]
        tag += " src=\"#{sexy_image.image.url(style_sym)}\""
        tag += " alt=\"#{opts[:alt]}\"" if opts[:alt]
        tag += " title=\"#{opts[:title]}\"" if opts[:title]
        tag += " />"

        return tag.html_safe
      end

      nil
    end
def sexy_image(term, opts = {:width => 100, :height => 100})

      # The loving is a mess, what happened to all of the feeling?
      # I thought it was for real; babies, rings and fools kneeling
      # And words of pledging trust and lifetimes stretching forever
      # So what went wrong? It was a lie, it crumbled apart
      # Ghost figures of past, present, future haunting the heart
      sexy_image = term.is_a?(SexItUp::SexItUpImage) ? term : SexItUpImage.where(['image_search_term = ?', term]).random

      if sexy_image.nil? || sexy_image.blank?
        puts "No image found.  Searching for #{term}."
        # No image object passed in or found; let's go search.

        sexy_image = SexItUpImage.find_all(term).random
      end

      unless sexy_image.nil?
        style           = "#{opts[:width]}x#{opts[:height]}"
        style_sym       = "s_#{style}".to_sym
        style_hash      = {style_sym => [style]}

        sexy_image.set_attachment_sizes(style_hash)
        sexy_image.image.reprocess! unless File.exist?(sexy_image.image.path(style_sym)) # No need for reprocessing if size already exists

        tag = "<img"
        tag += " class=\"#{opts[:class]}\"" if opts[:class]
        tag += " src=\"#{sexy_image.image.url(style_sym)}\""
        tag += " alt=\"#{opts[:alt]}\"" if opts[:alt]
        tag += " title=\"#{opts[:title]}\"" if opts[:title]
        tag += " />"

        return tag.html_safe
      end

      nil
    end
Pass in a search term (e.g. 'dogs') and the resolution you
  want the image to be displayed at.