How to you replace images with Dummy / Placeholder within WordPress Demo Export?

As I asked in the title, How to you replace Copyrighted images used in preview with Dummy / Placeholder within WordPress Demo Export?

What are the procedures? Any simple way?

Also, How do you handle users with No Internet Connection.

Can anybody give some help? it would be appreciated.


(There’s probably a better way of doing this)

  1. Download the /uploads/ folder of your server.

  2. Run a photoshop action over to heavily blur / crystallise all images in the folder

  3. Reupload as /uploadz/ (it’s important the character lengths are the same!)

  4. Find/replace your .xml /uploads/ for /uploadz/

That’s the one I’m trying now. But by changing filename. @tommusrhodus

Hope there will be a better way.

Try this:

And the actual web app:

1 Like

I usually create a whole new demo with dummy images that contains much fewer items than the original preview. I try to create a page that allows buyers to exactly see how every feature works, without spamming their media depot.

Worked well for us so far :slight_smile:

SecondLine said

Try this:

And the actual web app:

I’m not asking how to convert images with dummy. I already did that. now how replace it in WP Demo Content XML File ?


The problem with the proposed solutions is that all urls contained in custom meta values would still point to the demo site after the import which may be or may be not viable for the author.

To avoid such case, you’d need to rewrite each urls after the import making sure you don’t break the serialized value in the process.

I use and it works great! No need to have a web “dev” version of your theme for it to pull images from as it pulls the dummy images from

What I do each time is replace all strings containing wp-content/uploads on my local development path, with the placeholders path on my server.

With SublimeText if your server is localhost, and you put the images on your server in a folder named placeholder you can just select all http://localhost/themename/wp-content/uploads string, and replace with

Then copy all contents inside wp-content/uploads, create the thumbs using, upload to your server.

That should replace all path correctly even inside post content, and have your demo content ready to be imported :slight_smile:

I thinks, the best way to replace all your copyrighted images is to regex all your images in content.

I replace all images in content when I insert post programmatically in order created the demo from the live demo with copyrighted images:

$img_holder    = get_template_directory_uri() . '/includes/demo-installer/images/placeholder.png';
$post_content = (string) preg_replace('/="([^"]*\.(?:png|jpeg|jpg|gif|bmp))"/', '="'.$img_holder.'"', (string) $content->encoded);

You can also do that for your post_meta.

To replace all feature thumbnails, I automatically add them with random placeholder image like this:

function add_attachment() {
	global $add_post, $tt_post;
	define('IMGPATH', get_theme_root() . '/theme/includes/demo-installer/images/');
	$directory  = get_template_directory_uri() . '/includes/demo-installer/images/';
	$path       = wp_upload_dir();
	$images     = glob(IMGPATH.'{*.jpg,*.JPG,*.png}', GLOB_BRACE);

	foreach ($images as $image) {
		$filename     = basename($image);
		$media_exists = get_page_by_title($filename, 'OBJECT', 'Attachment');
		if ($media_exists == null) {
			if(wp_mkdir_p($path['path'])) {
				$file = $path['path'] . '/' . $filename;
			} else {
				$file = $path['basedir'] . '/' . $filename;
			$image_data   = file_get_contents($image);
			file_put_contents($file, $image_data);
			$wp_filetype = wp_check_filetype($filename, null );
			$attachment = array(
				'post_mime_type' => $wp_filetype['type'],
				'post_title'     => sanitize_file_name($filename),
				'post_content'   => '',
				'post_status'    => 'inherit'
			$attach_id   = wp_insert_attachment( $attachment, $file);
			$attach_data = wp_generate_attachment_metadata( $attach_id, $file );
			wp_update_attachment_metadata( $attach_id, $attach_data );		
			$attach_ids[] =  $attach_id; 
		} else {
			$query_images_args = array(
				'post_type' => 'attachment',
				'post_mime_type' =>'image',
				'post_status' => 'inherit',
				'posts_per_page' => -1,
			$query_images = new WP_Query( $query_images_args );
			foreach ( $query_images->posts as $image) {
				$image_url = wp_get_attachment_url( $image->ID );
				if (strpos($image_url,'placeholder')!== false) {
					$attach_id = $image->ID;
					$attach_ids[] = $attach_id;
	$post_IDs = get_option('post_IDs');
	$port_IDs = get_option('port_IDs');
	$post_ids = array_merge((array)$post_IDs, (array)$port_IDs);
	foreach ($post_ids as $post_id) {
		$attach_id = $attach_ids[array_rand($attach_ids)];
		set_post_thumbnail($post_id, $attach_id);

So, finally I just export my live demo and import it on a local host programmatically.
Then I just redownload the new demo with placeholder image.

It takes just 3-5min to create a formatted demo content without copyrighted images. This method works online and offline.

We created a simple plugin that automatically generates and replaces the images with placeholders in three simple steps.

The plugin reads the dimensions of your copyright images and creates an image of the same size and type.

Hope this makes the task easy