Preload Images

Descripziun

Preload Images loads the images you choose before the visitor needs them. It works well for photo galleries, sliders, hover images and other image-heavy pages where you want images to appear instantly.

Features

  • Add any number of image URLs that load on every page.
  • Add image URLs for a single page, post or custom post type from the editor.
  • Block editor (Gutenberg) support: a „Preload Images“ panel in the post sidebar, with an „Add from Media Library“ button.
  • Choose how images are loaded:
    • Background (JavaScript) loads images after the page has finished loading. This is the default and does not slow down the first render.
    • Preload adds <link rel="preload" as="image"> to the page head. Use it only for a few important above-the-fold images, such as a hero image.
    • Prefetch adds <link rel="prefetch"> so the browser caches images at low priority for the next pages a visitor opens.
  • Lightweight: no external requests and no extra script files on the front end.
  • Developers can change the list with the preload_images_urls filter.

Maletgs dal visur

Installaziun

  1. In your dashboard, go to Plugins > Add New.
  2. Search for „Preload Images“.
  3. Click „Install Now“, then „Activate“.
  4. Go to the Preload Images menu, add your image URLs (one per line) and choose a loading method.
  5. To set images for single pages, tick the post types under „Post Types“. A „Preload Images“ box then appears in the editor.

FAQ

Which loading method should I use?

Use Background (JavaScript) for most images. Use Preload only for one or two images that appear at the top of the page. Preloading many images makes the page slower. Use Prefetch for images that are shown on the next pages a visitor is likely to open.

Does it work with the block editor?

Yes. In the block editor, a „Preload Images“ panel appears in the post sidebar, where you can type URLs or pick images from the Media Library. The classic editor shows a „Preload Images“ box below the content.

The sidebar panel is used for post types that support custom fields (posts and pages by default). Other custom post types show the box below the content in both editors.

Can I change the URLs from code?

Yes:

add_filter( 'preload_images_urls', function ( $urls, $post_id ) { $urls[] = 'https://example.com/image.jpg'; return $urls; }, 10, 2 );

Reviews

Settember 20, 2022
I wanted to trigger an animated GIF on hover. To implement this, I followed a simple online guide to *swap* an image on hover – set initial image as the first frame of your GIF, and the second image as the animated GIF itself. This worked perfectly on desktop, but there was a small but very annoying flash on mobile (on touch). Enter this plugin! I enabled the plugin for pages (setting), then copy/pasted the URL of my GIFs in the 'Image URLs' field on my specific page … and voila! The flash is history! Thanks to the plugin author – Ravikumar Patel (@ravipatel) – for such a simple and neat solution for my unique case. 5/5 ⭐⭐⭐⭐⭐ PS: it took me longer to write a Support question followed by this review, than it did to actually apply the fix! 🙂
Avust 16, 2022
I run a photo gallery website for hobby using fancybox, and I'm happy to find this plugin! Initially I was searching for a solution with JavaScript, etc., but this is much easier way to preload images with relatively large file sizes. Thank you for the developers behind this!
Schaner 9, 2022
Sadly, the plugin does not work to preload a site's background image when that image is specified in common image urls. Plus, when there is no image specified in the common image urls, the site loads as a blank page with what I can only describe as a spinning waiting icon. Once the spin is done the site does load smoothly with the background image. But, who wants clients seeing a site that loads with a spinning icon for 3 seconds? Hopefully they'll update so that the background image can be specified in the common image urls, because it does seem an easy to use plugin.
December 12, 2021 1 reply
I found myself needing to pre-load some images and started to figure out how to do it by hand when I thought "If you have a need in WordPress, there's probably a plugin for it." So I went hunting and found this plugin. Gutenberg made it a little hard to see the meta box on Pages at first, but I found it. I REALLY like that you can preload per page/post, or have them global. Nicely done.
Fanadur 17, 2021
I am very thankful for this plugin, and of course the person/s who created it. My client wanted an image carousel as the homepage header, which resulted in short loading delays the first run through. Since using this plugin — no delays! Pretty cool stuff.
Read all 8 reviews

Contributors & Developers

“Preload Images” is open source software. The following people have contributed to this plugin.

Contributors

“Preload Images” has been translated into 1 locale. Thank you to the translators for their contributions.

Translate “Preload Images” into your language.

Interested in development?

Browse the code, check out the SVN repository, or subscribe to the development log by RSS.

Changelog

1.3.0

  • New: block editor (Gutenberg) sidebar panel with Media Library picker.
  • New: choose a loading method: background JavaScript, <link rel="preload"> or <link rel="prefetch">.
  • New: preload_images_urls filter.
  • New: plugin data is removed when the plugin is deleted.
  • New: updated screenshots.
  • Fix: the „Settings“ link on the Plugins screen pointed to the wrong page.
  • Fix: URLs containing & were double-encoded and could break. Existing saved URLs are cleaned up automatically on upgrade.
  • Fix: per-page images were not used on some archive pages.
  • Fix: per-page images of password-protected posts are no longer shown before the password is entered.
  • Improved: security hardening, escaping and coding standards.
  • Improved: the background script no longer adds global JavaScript variables and runs after the page has loaded.
  • Tested with WordPress 7.1. Requires WordPress 6.1 and PHP 7.4.

1.2.1

  • Bug fixes

1.2

  • Now you can manage images for single pages and post types.
  • PHP code changes.
  • Tested with WordPress 5.6.

1.1

  • Minor code changes.
  • Tested with WordPress 5.5.1.

1.0

  • Initial release.