Skip to main content

Using Sirv on WordPress - Installation and configuration

WordPress logoThe standard media options for WordPress websites can be quite limiting. The Sirv plugin changes that, giving you instant control over your media library, helping you deliver images perfectly optimized for the web. Sirv removes the hassle of image management, with a single media library to embed images anywhere online (not just in WordPress). With WooCommerce support, you can leverage Sirv's most powerful features: amazing 360 spins, multiple image zoom effects and product videos to help you increase sales.

Install Sirv on WordPress​

Simply install the plugin from your WordPress admin, with the following steps. Alternatively, download the zip from our official WordPress CDN plugin page. 1. Go to the Plugins section of your WordPress admin and click "Add New": WordPress Plugins 2. Search for "Sirv": Search for Sirv in the WordPress plugin directory 3. Install and then activate the plugin: Install Sirv on your WordPress website 4. Go to the "Settings" page for Sirv:

Sirv for WordPress settings page
5. If you have an active Sirv account, just enter your login details:
Copy S3 details from Sirv to WordPress
If you don't have a Sirv account, you can create it in the plugin itself or by visiting our website:
Copy S3 details from Sirv to WordPress
Congratulations, Sirv is now installed! Your free trial includes 5GB of storage and 20GB of bandwidth.

Configure Sirv for WordPress​

Enable Sirv​

To start serving WordPress media with Sirv, enable it in the settings. Sirv will automatically fetch images from your server, when they are requested. It's very fast - each image usually syncs within 1 second - but if your server is slow, the initial load for the first ever user might feel delayed. To avoid this, run a manual sync for the perfect user experience.

Enable Sirv for WordPress

Sync your media library with Sirv​

Synchronize your media library in advance, for a faster user experience:

Sync media library with Sirv

Sync your theme files with Sirv​

If you'd like to speed up the delivery of your theme files too, you can sync CSS images with Sirv. Choose the active theme or a folder for Sirv to scan for the images.

Sync WordPress theme files from your CSS
A more in-depth tutorial is available here.

Exclude files from Sirv​

If you don't want some images to be served by Sirv, you can exclude them:

Exclude files from being synced to Sirv

Disable lazy loading and responsive scaling​

Sometimes you may want to serve an image from Sirv CDN but not apply automatic scaling and lazy loading from Sirv JS. There are multiple ways to disable lazy loading and image scaling:

  • URL - simply add the path to the image, starting with a forward slash and the WP folder e.g. /wp-content/uploads/....
  • URL + wildcard - add the image path, with a * character to exclude images in a certain folder or with a certain file name pattern. For example, this would exclude all PNG images in the Example folder /wp-content/uploads/Example/*.png.
  • img attribute - exclude files with a particular class, alt or data in the img. For example, MyLogo would exclude this image .
Exclude images from lazy loading and responsive scaling

Choose how to load Sirv​

Sirv JS is responsible for lazy loading, responsive imaging, and Sirv media (spin, zoom, video). You have several options to choose from on how to load it.

How to load Sirv JS
1. Detect. Sirv JS will only be loaded on pages that use Sirv features. Recommended option. 2. Include Sirv on all pages. Choose this if you have problems with the second option. 3. No pages. Choose this if you are going to implement Sirv JS by yourself and know what you're doing.

Custom domain​

During registration, you have the option to choose a custom Sirv sub-domain that will be associated with your account, like abcwidgets.sirv.com. If you'd like to use your own domain, for example - media.abcwidgets.com, follow these instructions.

Make use of custom profiles​

Sirv has a neat feature called profiles, which allows you to change your image settings in bulk. You can apply different settings (quality, watermarks, overlay text and many more) to your images, as well as any other Sirv shortcodes you create:

Enable custom profiles for Sirv in WordPress

Image optimization​

The Sirv plugin automatically serves as many images as possible. The number of best-practice optimizations depends on the source of the image:

OptimizedNext-gen formatsScaledLazy loadedCDN
Synced imagesYesYesYesYesYes
Parsed imagesYesYesNoNoYes
CSS background imagesYesYesNoNoYes
Sirv Media imagesYesYesYesYesYes

Many options existing for configuring a Sirv media gallery on your WooCommerce product page. If you need even greater control of the gallery, that is also possible, by adding a filter to add, remove or modify items.

This technique requires a script which should be written by a web developer. In general:

apply_filters("sirv_pdp_gallery", array $items, int $product_id )

In that filter, $items should be an array of objects and $product_id should be the WooCommerce product ID (integer).

Items in the gallery can be any of these values:

  • image
  • spin
  • video
  • model
  • youtube
  • vimeo

Each item has these fields:

  • url - item URL e.g. https://demo.sirv.com/tshirt-aqua.spin or https://demo.sirv.com/video.mp4
  • type - item type: image, spin, video, model, online-video, wc_placeholder_image
  • provider - where file is hosted: Sirv or WooCommerce
  • viewId - WooCommerce product ID or variation product ID
  • caption - item caption (empty by default)
  • order - order of item in the gallery thumbnails

Except for videos from YouTube or Vimeo, which have some differences:

Example:

add_filter("sirv_pdp_gallery", "callback_func", 10, 2);

function callback_func($items, $product_id){
//do something with items
return $items;
}

In some cases, the WooCommerce placeholder wc_placeholder might be the first item in the gallery. That placeholder should have item type wc_placeholder_image. If you want to modify the gallery, you may wish to remove the placeholder by checking if wc_placeholder_image is the first item, so you can remove it.

The order field can be filled with 0. After applying the filter, the order will be recalculated.

Product CSV export​

The Sirv plugin saves meta information into a database, to track which images are associated to which products. This data can be seen in the WooCommerce product export CSV. The plugin adds these meta fields:

  • sirv_woo_product_image - Image URL of the Sirv product image.
  • sirv_woo_product_image_attachment_id - Attachment ID for each image URL.
  • _sirv_woo_gallery_data - Data about Sirv assets in the product gallery, (JSON string).
  • _sirv_woo_viewf_status - Parse status of whether .view request returned an image.
  • _sirv_woo_viewf_data - Data about the last attempted .view request (JSON string).

FAQ​

\

Help from a Sirv expert​

If you have any questions about how to use the Sirv for WordPress plugin, please contact our support team from your Sirv account.