WordPress.org

Forums

Jetpack by WordPress.com
[resolved] [closed] Jetpack Always Adding "Scale" to Image URLs on Retina Devices (11 posts)

  1. WPMonkeyATL
    Member
    Posted 1 year ago #

    Hello - Seems there's an odd behavior with the way Jetpack is implementing its "Retina Readiness" capabilities: it ALWAYS modifies image URLS and includes a "scale=" attribute on ALL images that are delivered to retina devices (e.g. iphone 5S, iPad Air, etc).

    Jetpack does this even if no modules within Jetpack are activated. Meaning, if you only install the Jetpack plugin and activate it and do nothing more (i.e. do not enable any Jetpack modules, do not connect to your wordpress.com account), then all image URLs delivered to retina devices are modified with the "scale=" attribute.

    I understand Jetpack retina-fies it's own icons as well as tiled image galleries etc. But across-the-board modification to all image URLs (even your own images inside your posts) on retina devices seems rather invasive: without Photon or Tiled Galleries enabled, the images displayed on the retina device won't be true retina anyway (i.e. 2x normal resolution).

    Meanwhile, such across the board URL modification can cause conflict with other plugins (e.g. the "Retina 2x" plugin for example).

    Is there any way to prevent Jetpack from making such across-the-board modifications to image URLs on retina devices? Or perhaps, only allow Jetpack to do this on it's "own" images (e.g. UI icons, etc).

    To see this behavior in action, try this:

    1. Turn on your favorite browser developer tools to be able to inspect elements on mobile responsive and retina devices (e.g. in Firefox: go to about:config and set layout.css.devPixelsPerPx=2 and also turn on responsive design view and set size to phone display size)

    2. Disable Jetpack plugin altogether. Browse your post with any image on it and hit "Inspect Element" on the image: you will see the pure image URL as you would expect.

    3. Now Activate Jetpack plugin (disable all Jetpack modules, disconnect from wordpress.com i.e. install a pristine and activated Jetpack plugin and nothing more). Browse the same post image and hit "Inspect Element": now you will see that the image URL has been modified by Jetpack to includes a "scale=" attribute.

    Does anybody have any ideas on how to suppress such across-the-board image URL modification by Jetpack? Is there a CSS trick that might prevent this?

    Thanks in advance.

    http://wordpress.org/plugins/jetpack/

  2. Jeremy Herve
    Happiness Engineer
    Plugin Author

    Posted 1 year ago #

    The scale parameter should only be added when necessary, so you might have found a bug. Could you post your site URL here, so I can have a look?
    If you want it to remain private, you can also contact us via this contact form:
    http://jetpack.me/contact-support/

    You can also use this function to disable this feature on your site.

    function dequeue_devicepx() {
    wp_dequeue_script( 'devicepx' );
    }
    add_action( 'wp_enqueue_scripts', 'dequeue_devicepx', 20 );

    You can also read more about how devicepx works by looking at the file here:
    http://s0.wp.com/wp-content/js/devicepx-jetpack.js?minify=false

  3. WPMonkeyATL
    Member
    Posted 1 year ago #

    Hi Again - Thanks so much for your reply, and I will be sure to try your suggestion. To answer your question, you can see the "scale" attribute appear on any image URL from any wordpress site that has Jetpack activated on it (e.g. self-hosted wordpress sites). Meaning, it is not particular to any of my sites.

    See Step #1 in my original post above for one way to be able to see the actual HTML that gets delivered - either way, just remember to set up your browser developer tools to (a) responsive mode and (b) 2x resolution mode to simulate a Retina device.

    For example, you can experience this on these site which has Jetpack on it (do inspect element on any image on this site):
    http://www.mojowill.com/

    Thanks so much for your help. I will try your suggestion and post results soon.

  4. WPMonkeyATL
    Member
    Posted 1 year ago #

    Jeremy - Great News: I just included the function you suggested above to disable "devicepx" in my functions.php, and it solves the issue, the "scale" attribute no longer appears on image URLs. So your suggestion fixed the problem!

    The result is that now the previous conflicts that Jetpack caused with other plugins (e.g. "Retina 2X") are avoided.

    Please let us know by posting here if you discover that this is in fact a bug as you suspect. In the meantime, I'll keep your fix in my functions.php.

    Thanks again.

  5. Jeremy Herve
    Happiness Engineer
    Plugin Author

    Posted 1 year ago #

    To answer your question, you can see the "scale" attribute appear on any image URL from any wordpress site that has Jetpack activated on it (e.g. self-hosted wordpress sites).

    The scale attribute is indeed added to all images, but it is set to 0 when devicepx detects that the images can't be enlarged. Is the scale attribute set to anything else on your end?

  6. WPMonkeyATL
    Member
    Posted 1 year ago #

    Yes, as you indicate, Jetpack seems to set scale=0" on all images (and also sets the intended width= and height= properties as intended on the post image insertion definition itself). But it appears this scale="0" may be what causes conflict with other plugins (notably Retina 2x).

    The conflict I found was that Retina 2X would then change it to scale="2" but also adjust the width= and height= property values to be much smaller than the original values, thus "hard-wiring" the image size and causing it to not properly adjust on an ipad when turning devices from portrait to landscape. Since the width and height were hardwired for the portrait orientation, it would look small on landscape.

    However the fix you provided above eliminates the scale="0" altogether, removing conflict with the Retina 2x, which will now leave the width/height at the original values and thus not cause display issues on portrait/landscape re-orientation.

    Thank again for your suggested fix.

  7. Jeremy Herve
    Happiness Engineer
    Plugin Author

    Posted 1 year ago #

    But it appears this scale="0" may be what causes conflict with other plugins (notably Retina 2x).
    [...]
    However the fix you provided above eliminates the scale="0" altogether, removing conflict with the Retina 2x

    Glad to hear you're all set. You probably don't need 2 Retina plugins though, or you may run into conflicts, as you've experienced. So disabling Jetpack's Retina library was probably a good idea. :)

  8. WPMonkeyATL
    Member
    Posted 1 year ago #

    Jeremy - I think the basic issue is that by default Jetpack adds scale="0" to all images, not just those images it "controls" which would Jetpack-related UI icons and importantly the Tiled Gallery thumbnails.

    Tiled Gallery thumbs always require the WP CDN in order to process the Tiled thumb layout. If you want a Tiled gallery to appear Retina then you must let WP CDN process those tiles, else they won't appear as Retina. So by disabling Jetpack's retina library using your suggestion, you lose the Retina display of Tiled gallery thumbs as they must be processed by WP CDN regardless.

    But if you insert any specific images into your post (e.g. a Medium or Large single image insertion), these will not appear as Retina unless Photon is enabled. However, even if you choose not to use Photon, Jetpack still adds the Scale property - that's the invasive part (because such inserted images are not required to always be processed through WP CDN).

    If you use the Retina 2X plugin to "retinize" such inserted post images (instead of the WP Photon approach), then the scale property conflicts with it. This conflict can be avoided using your suggestion above.

    But then you end up with the Tiled gallery no longer displayed as retina because those tiles are always processed by the WP CDN no matter what.

    So looks like a catch 22: seems that Jetpack adding scale across the board invites conflict with other plugins, and disabling it across the board causes Tiled galleries to not show as Retina since they are always processed by WP CDN.

    Maybe Jetpack should not always add the scale attribute across the board but only to those images it absolutely must control. Then, if Photon is enabled, maybe that could enable Jetpack to further add scale to the other images as well (since you'd need Photon anyway for those other images to be retina-fied by Jetpack).

    Thoughts? Many thanks as always.

  9. Jeremy Herve
    Happiness Engineer
    Plugin Author

    Posted 1 year ago #

    Maybe Jetpack should not always add the scale attribute across the board but only to those images it absolutely must control.

    Noted! I've asked our Retina expert to take a look, and see what we can do. I'll post again here when I have some news.

    Thanks!

  10. nicolasfox
    Member
    Posted 1 year ago #

    Just bumping this thread here. Same problem. Has anyone addressed this now that it's 5 months later?

    thanks
    Nick

  11. esmi
    Forum Moderator
    Posted 1 year ago #

    If you require assistance then, as per the Forum Welcome, please post your own topic instead of tagging onto someone else's topic.

    I am now closing this 5 month old, resolved, topic as it references an older version of WordPress.

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Jetpack by WordPress.com
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic

Tags

No tags yet.