fzaninotto / Faker

Faker is a PHP library that generates fake data for you
MIT License
26.8k stars 3.57k forks source link

Fetch images from own database or google drive / amazon aws #2002

Open jackbali opened 4 years ago

jackbali commented 4 years ago

Hello everyone,

I'm new here and I really hope my comment / request will not be annoying, I'm using faker and I really like it, I would just understand if would be possible instead to use images from lorempixel use my own images and fetch them from a online database ( google drive / amazon aws).

I've tried to search but I could not find something to help me.

Thanx in advance for your support.

jayenne commented 4 years ago

Faker it doesn't do anything other than create a url to put in your database.

Faker->imageUrl doesn't "deal with images" it simply constructs a url for the lorempixel website. it's the orempixel that resolves it to an image.

So, If you know the url/path/filename for your images then you don't need to use faker for that, you just set your field to it OR create a function to contruct the path for you then poplate the field with that.

e.g.. faker->imageUrl($width = 640, $height = 480) will return the value "http://www.lorempixel.com/" for you to then add to your database: $avatar = $faker->imageUrl($width = 640, $height = 480)

if you have your own image urls then you simply use that instead of Faker.. 'avatar' = $my_image_url or call a function to construct one for you* 'avatar' = myImageUrlGenerator($arg1,$arg2...);

*You could write your own Faker provider to do this.

If you don't have a resolvable URL to a specific image then you will need to write a function to server images based on your specific needs. this could include sizes, effects, subjects etc... but that's all your own work.