Join

Prevent Media From Being Duplicated When Cloning Listings

Don't want to mess with code snippets? This is a feature of MyListing Pro.

Instructions

  1. Create a new PHP code snippet.
  2. Copy the contents of code snippet below.
  3. Paste the contents into your code snippet.
  4. Review any notes that I’ve provided.
  5. Save and enable the code snippet.
  6. Test.

Snippet

By default, when you clone a listing that has images (logo, cover, gallery, etc.), those images will be duplicated, filling up your WordPress Media Library.

The code snippet below reuses the same files when cloning a listing instead of re-uploading and duplicating them.

PHP
add_filter( 'mylisting/duplicate-listing/reuse-file-uploads', function( $reuse, $original_listing, $duplicate ) {
    return true;
}, 10, 3 );