retinajs icon indicating copy to clipboard operation
retinajs copied to clipboard

Retina displays - 404 error when there is no @2x image

Open pixel-industry opened this issue 9 years ago • 14 comments
trafficstars

Hi,

we are facing a problem with retina.js on retina screens. We have premium template that has no retina images, but we use the script because of our buyers, so they don't have to include it by themselves.

The problem is that template doesn't have retina images, only regular ones. On MAc, retina display, the normal image apears, but script is generating 404 errors in console (as it can't find @2x images). Can you help us to solve this issue. I think that the script should just ignore if there is no retina images, not showing 404 error in console. Here is the link to template in question: http://www.pixel-industry.com/html/trucking/

Thank you in advance.

Kind regards, Andrijana

pixel-industry avatar Feb 29 '16 11:02 pixel-industry

This is not a bug, it is a feature. On HTTP methods, even OPTIONS, HEAD or GET they obviously return 404 Not Found if the file is not found. Retina.js performs this to check if the file exists to be replaced... So, if you want, you can add data-no-retina to your images tags to avoid requesting the retina version of them. It is in the docs.

lucasff avatar May 10 '16 14:05 lucasff

Wouldn't it be easier to add a class for images that has hi-res copy and avoid tons of 404 errors that are really bad...

djalexa avatar May 11 '16 11:05 djalexa

I agree, but this breaks backwards-compatibility. Maybe for 2.0 @strues ?

clemensg avatar May 11 '16 12:05 clemensg

This is fixed in version 2.0 of Retina.js. We'll be releasing it officially in the next couple of days.

strues avatar Jun 13 '16 00:06 strues

Has this been fixed? I am using v2.1 and still get 404 errors in my console.

Smitty17 avatar Mar 30 '17 23:03 Smitty17

The project seems to be abandoned

kleuter avatar Mar 31 '17 07:03 kleuter

Sorry guys I lost the ability to merge code after the company which put out RetinaJS went under.

strues avatar Mar 31 '17 17:03 strues

Thanks for the update. I'll see if I can fix it. Cheers.

Smitty17 avatar Mar 31 '17 17:03 Smitty17

No problem. I'll see what I can do about getting write permission

strues avatar Mar 31 '17 17:03 strues

Years later, is this code available for me to implement myself?

terzom avatar Oct 15 '18 09:10 terzom

Hi there, do you guys have any good news about this problem?

steve231293 avatar Feb 20 '19 03:02 steve231293

Hi, is there already a solution for this?

melesch avatar Dec 03 '19 15:12 melesch

Add this to the .htaccess

# This block of code needs to go above your Wordpress rules
<IfModule rewrite_module>
  #This is to short circuit non existent Retina image requests generated by retina.js
  # without this, the whole wordpress 404 stack will be executed which is very expensive
  # We simply redirect the request to the non @2x version of the file, if one exists, otherwise, send a 404 status
  RewriteEngine on
  RewriteBase /
  RewriteCond %{REQUEST_FILENAME} @2x\.[a-z]+$
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteRule ^(.*)@2x(.*)$ $1$2 [E=NORETINA:1]
  RewriteCond %{ENV:NORETINA} 1
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteRule .* - [L,R=404]
</IfModule>

melesch avatar Dec 03 '19 16:12 melesch

do this // i.setAttribute("src", e), in line 28

nouser33 avatar Feb 09 '24 15:02 nouser33