faker icon indicating copy to clipboard operation
faker copied to clipboard

Add image_file method to Placeholdit module

Open nicolas-brousse opened this issue 8 years ago • 2 comments

Hey,

Are you interested about a method to directly retrieve a file instead a url with Placeholdit module. The idea is to easily create attachment on an app without downloading the image file from URL.

Right now a created a method to do the job but may be it's something that could be done directly by Faker.

    def image_file(size = '300x300', format = 'png', background_color = nil, text_color = nil, text = nil)
      download_file image(size, format, background_color, text_color, text)
    end

    private

    def download_file(url)
      file = Tempfile.new("faker_placeholdit")
      file.binmode
      file << Net::HTTP.get(URI(url))
      file.close

      File.new(file.path)
    end

What do you thing about ? If you think It's interesting, let me know and I could work on a pull request.

nicolas-brousse avatar May 17 '18 13:05 nicolas-brousse

@vbrazo if you added the "feature request" tag, does that mean you'll accept a PR on this? 🤔

aamarill avatar May 23 '18 04:05 aamarill

@aamarill no, I'm just categorizing the PRs and issues, so we can focus on the categories that we prefer.

vbrazo avatar May 23 '18 15:05 vbrazo