wp-sync-db / wp-sync-db-media-files

Sync media libraries between WordPress installations - an addon for wp-sync-db
GNU General Public License v2.0
530 stars 142 forks source link

Skip resized images #37

Open darksam1995 opened 5 years ago

darksam1995 commented 5 years ago

First of all, Thank you for this awesome plugin.

Can you please tell me how can I skip file migration of resized images. I want to download only the main images not (image-100X100.jpg)

Please let me know how can i do it, i can edit files easily and know php also.

Thank you. :)

darksam1995 commented 5 years ago

Open File::: wp-content/plugins/wp-sync-db-media-files-master/wpsdb-media-files.php

function add_files_to_migrate( $attachment, $remote_media ) {
    if( isset( $remote_media[$attachment['file']] ) ) {
        $this->files_to_migrate[$attachment['file']] = $remote_media[$attachment['file']];
    }
    //if( empty( $attachment['sizes'] ) || apply_filters( 'wpsdb_exclude_resized_media', false ) ) return; //change false to true
    if( empty( $attachment['sizes'] ) || apply_filters( 'wpsdb_exclude_resized_media', true ) ) return; //change false to true
    foreach( $attachment['sizes'] as $size ) {
        if( isset( $remote_media[$size] ) ) {
            $this->files_to_migrate[$size] = $remote_media[$size];
        }
    }
}

function maybe_add_resized_images( $attachment, $site_b_media, $site_a_media ) {
    //if( empty( $attachment['sizes'] ) || apply_filters( 'wpsdb_exclude_resized_media', false ) ) return; //change false to true
    if( empty( $attachment['sizes'] ) || apply_filters( 'wpsdb_exclude_resized_media', true ) ) return; //change false to true
    foreach( $attachment['sizes'] as $size ) {
        if( isset( $site_b_media[$size] ) && ! isset( $site_a_media[$size] ) ) {
            $this->files_to_migrate[$size] = $site_b_media[$size];
        }
    }
}