Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Resource interpreted as Document but transferred with MIME type image/jpeg

I'm using Filepicker.io to handle my image uploads on my website.

I'm also using FancyBox to display a nice slider. Everything works fine if I use a regular image like: http://i.imgur.com/asdf.jpeg as the <img src="">. Meaning I click the images and the slider pops up correctly.

However when I switch out those static image url's and use my Filepicker addresses, when I click on the images to open the fancybox, the image is downloaded.

Here's the message I get in the console, on Google Chrome:

Resource interpreted as Document but transferred with MIME type image/jpeg: "https://www.filepicker.io/api/file/yknn4hWSOOm2NLZYGR3O?dl=false".

Any suggestions?

like image 766
sergserg Avatar asked Dec 21 '12 05:12

sergserg


2 Answers

Since your link:

https://www.filepicker.io/api/file/yknn4hWSOOm2NLZYGR3O?dl=false

doesn't have an image extension (jpg, png, gif), fancybox doesn't know what type of content needs to be handled. You need to tell it by adding the API option "type": "image" like:

$(".fancybox").fancybox({
   "type": "image"
});

That is documented here http://fancybox.net/faq, No. 6 (if using v1.3.4), or here http://fancyapps.com/fancybox/#support, FAQ tab, No. 5 (if using v2.x).

For more options how to handle the issue see here: https://stackoverflow.com/a/17554660/1055987

like image 61
JFK Avatar answered Nov 18 '22 13:11

JFK


Another option is to append the name of the file onto the url, for example: https://www.filepicker.io/api/file/yknn4hWSOOm2NLZYGR3O+photo.png?dl=false

Filepicker.io ignores anything on the file link after the + sign to allow you to make the urls more "adapter friendly"

like image 45
brettcvz Avatar answered Nov 18 '22 12:11

brettcvz