Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alternate Retina js Parse error on wordpress #49

Closed
drivebass opened this issue Apr 17, 2012 · 3 comments
Closed

Alternate Retina js Parse error on wordpress #49

drivebass opened this issue Apr 17, 2012 · 3 comments

Comments

@drivebass
Copy link

I use the default js script with a Wordpress 3.3 website and it works perfect.

echo "<script>document.cookie='resolution='+Math.max(screen.width,screen.height)+'; path=/';</script>";

When i change the default js with the alternate one for retina support (copied from the adaptive-images website) inside the echo command:

echo "<script>document.cookie='resolution='+Math.max(screen.width,screen.height)+("devicePixelRatio" in window ? ","+devicePixelRatio : ",1")+'; path=/'; </script>";

it returns a parse error:
Parse error: syntax error, unexpected T_STRING, expecting ',' or ';'

I've noticed that for the script you posted on your reply for Issue #36 (closed) you use different syntax:

<script>document.cookie='resolution='+(Math.max(screen.width,screen.height)*("devicePixelRatio" in window ? devicePixelRatio : 1))+'; path=/';</script>

I tried this version too but still returns the same error.

@MattWilcox
Copy link
Owner

It's because there are a mix of ' and " in there. Just change all the " to ' in the JS and you'll be fine. It's because PHP thinks the " is the end of a PHP instruction, when it isn't.

@drivebass
Copy link
Author

Never crossed my mind, so simple! It worked great! Many thanks Matt! Your solution for the adaptive images is awesome!

@MattWilcox
Copy link
Owner

Cheers :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants