How to alter import jobs to import external images

Our External Images plugin alters WordPress to allow you to use featured images and image galleries that are hosted off-site, often on an affiliate CDN, sometimes on Amazon S3.

There are two reasons why this is desired – the first being the vast reduction in storage requirements for your server and the second being significant speed boosts for import jobs.

When you import products or posts that included featured images, WordPress loads the full size image to your uploads folder but it also creates multiple resized copies of this image, depending on how many image sizes you have registered on your website. This uses CPU and disk.

How to alter import jobs

The essentials are very simple. Do not import ‘featured images’ or ‘gallery images’ using the normal images feature of your import tool. Instead, you map these fields from your import to a meta field called external_image_url. This meta field can contain multiple images separated by the pipe | symbol and the first image will become your featured image.

Here’s an example using WP All Import – in the image below, you’ll see the typical set up where images are configured to be downloaded to your server.

So – in the example above, the source field in the import is {imageurl[1]}. To update this import job to work with External Images, you simply delete this {imageurl[1]} from the Images import and put the {imageurl[1]} into the Custom Fields area below it.

Now when you run your import, WP All Import will treat your {imageurl[1]} field like a standard text custom meta field and will not process the images. The External Images plugin will spot that this external_image_url field is populated and will use it to create your featured images.

Importing multiple images into your gallery

If you have multiple images for your posts or products or custom post types, External Images also handles that. Simply copy all of those image URLs to the external_image_url custom field and separate them with the pipe | symbol.

Here’s an example:

Force External Images to recheck images

When you load image URLs to the external_image_url field, the first time the post/product is viewed containing that field the plugin will split apart these image URLs and create the external featured image and the external image gallery for you. This includes measuring the size of the external images and checking that they exist.

To save time and server resource and avoid having to check image sizes every time, the custom meta field ‘ei_converted’ is set to 1.

If this field gets set back to zero or deleted, the plugin will rescan the external_image_url field to pick up the images again.

There is an action hook added to the update_post_meta WordPress function which will catch the vast majority of cases when the external_image_url field is modifying – for example, when you are re-importing image fields for existing items. This hook deletes the ei_converted field so that the External Images plugin will rescan the external_image_url field for new images.

In some rare cases you may be bypassing this WordPress action hook – e.g. using the WP All Import speed boosting option to bypass do_action – if this applies to you, you should ensure you set ‘ei_converted’ to 0 (zero) to force the plugin to rescan your freshly imported images.

 


Did this article answer your question?

2 Comments

  1. byron


    April 20, 2020 @
    2:34 am

    the image is the actual name of the image. ie. image.png
    If i store this image on an external url, where do I add the path to that image?
    ie: 127.0.0.1/mysite/images

    Reply

    • Dave H.


      April 22, 2020 @
      4:30 pm

      Hi – in WP All Import you would set the external_image_url field to:

      https://127.0.0.1/mysite/images/{imagefield}

      The curly braces part will be whatever fieldname you drag over using WP All Import.

      Reply

Leave a Reply

Your email address will not be published. Required fields are marked *


No Comments

  1. byron
    April 20, 2020 @ 2:34 am

    the image is the actual name of the image. ie. image.png
    If i store this image on an external url, where do I add the path to that image?
    ie: 127.0.0.1/mysite/images

    Reply

    • Dave H.
      April 22, 2020 @ 4:30 pm

      Hi – in WP All Import you would set the external_image_url field to:

      https://127.0.0.1/mysite/images/{imagefield}

      The curly braces part will be whatever fieldname you drag over using WP All Import.

      Reply

We use cookies

We use cookies for various things on our site, including our on-site chat bubble (if you use it), our comment forms (if you use them) and for session handling (if you log in).

Other than that, we use cookies to identify where traffic came from to help us understand which traffic turns into sales, we use a cookie for Google Analytics traffic analysis and we use a cookie to customise adverts for our own products we think you'll be interested in.

You can read more detail in our privacy policy page. Please click 'Accept' or 'Decline' to continue.