Reputation: 117
i am creating a rails application and i wanna user to be able to enter link for his/her profile picture from Facebook or any external site .
how to be sure this link is for image?? how to create a validation for that ??
Upvotes: 0
Views: 583
Reputation: 1208
Use this validation in model.
validates_format_of :image, :with => %r{\.(png|jpg|jpeg)$}i, :message => "Use a real image"
Please be aware that this would only validate that the filename would end in a specific string.
Use fastimage to get type and size of images by quickly fetching. eg.
FastImage.type("http://stephensykes.com/images/pngimage")
returns .png
Upvotes: 1