• Den

    (@denmayday)


    Hi and thanks for the great plugin!

    However I had few issues with it:

    1) When importing images (post_thumbnail) with the same name they will overwrite each other. Lets say I have weird image names like this:
    …/dir1/1.jpg
    …/dir2/1.jpg
    …/dir3/1.jpg
    So when I import those files I end up with posts having the same image (last one from dir3) rather then 3 different images.

    Here is how I fixed it by adding post name to an image name:
    In file /wp-content/plugins/really-simple-csv-importer/rs-csv-importer.php find this line of code (#137)
    $post_thumbnail = remote_get_file($post_thumbnail,'');
    and replace it with this code
    $post_thumbnail = remote_get_file($post_thumbnail,'',$post_name.'_');

    then in file /wp-content/plugins/really-simple-csv-importer/wp_post_helper/class-wp_post_helper.php
    find this code (#347)
    function remote_get_file($url = null, $file_dir = '') {
    and replace with this
    function remote_get_file($url = null, $file_dir = '', $name_prefix = '') {

    then this code (#372)
    $photo = $file_dir . basename($url);
    replace with this
    $photo = $file_dir . $name_prefix . basename($url);

    2) When images are imported they don’t have title.
    To fix that in file rs-csv-importer.php find this code (#137)
    if ($thumbnail) $ph->add_media($thumbnail,'','','',true);
    and replace with
    if ($thumbnail) $ph->add_media($thumbnail,$post['post_title'],'','',true);

    Hope this will help someone.

    Thanks to the plugin author again.
    Cheers.

    https://wordpress.org/plugins/really-simple-csv-importer/

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Images with same name overwrite each other and no image title fix’ is closed to new replies.