Prevent images from being imported into my website

This tutorial explains how to prevent images from being imported into your website's Media Library. This can be useful if you have a lot of products and don't want to fill up your site's storage.

IMPORTANT - It's important to remember that this technique will serve the images directly from the merchants server. If the merchant's images are not HTTPS, they may not display on your site. Also, you can not take advantage of using the img srcset attribute causing large images to be loaded on mobile devices.

First, you need to make sure you have the Custom Code plugin installed and activated. Learn more here.

Then add the following code to your Custom Plugin:

function mycode_dont_import_images( $url, $image_importer ) {
	return '';
}

add_filter( 'datafeedr_image_importer/url', 'mycode_dont_import_images', 10, 2 );

Next, add this code to your custom plugin.

Save your change. 

Now, when new products are imported into your site, their images will not be imported.

NOTE - Previously imported images will not be removed from your site and will still be displayed alongside your images which are displayed from external URLs.

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.

Still need help? Contact Us Contact Us