Support » Plugin: Really Simple CSV Importer » Check if the attachment already exists

  • Is there a way to make the plugin check if there’s already an attachment in the media library for the imported image and attach the existing image to the post as post thumbnail without creating a new attachment in media library?

    Let me explain.

    I’m importing 100 posts. But there are only 20 images for all posts, because some posts use the same images as post thumbnails.

    The desired result is to get 20 new attachments in the media library after the import.

    However I’m getting 100 attachments with individual IDs, even if they link to the same 20 physical images.

    WordPress allows to attach the same image as post thumbnail for several posts.

    Is there a way to make the plugin do the same instead of creating several attachments with the same image source?

    Thanks for the great plugin and you efforts.

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

Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Author Takuro Hishikawa

    (@hissy)

    In short, not supported in current version(0.5.7).

    But I will release a new version that supports more flexibility in few days, please wait patiently…

    Thread Starter ninetienne

    (@ninetienne)

    Thanks, Takuro for your quick response.

    When do you think you could release the new version?

    Plugin Author Takuro Hishikawa

    (@hissy)

    I’ve released new version, and here is an example.
    https://gist.github.com/hissy/1ea54a46fd07be9f4334

    Thread Starter ninetienne

    (@ninetienne)

    Thanks Takuro. What should I do with the gist? Show I find the class rscsvimporter_replace_save_post in the old plugin version and replace with the new one from your gist?

    Plugin Author Takuro Hishikawa

    (@hissy)

    In version 0.6, RS_CSV_Importer::save_post() method is overridable with “really_simple_csv_importer_class” filter hook. You’ll be able to replace saving process as you like. The gist is an example, it enables to attach default thumbnail image via attachment id for each posts.

    Thread Starter ninetienne

    (@ninetienne)

    After updating the plugin I get an error: Parse error: syntax error, unexpected T_PAAMAYIM_NEKUDOTAYIM in \wp-content\plugins\really-simple-csv-importer\rs-csv-importer.php on line 350

    Thread Starter ninetienne

    (@ninetienne)

    fixed it by replacing $class::save_post by $class->save_post

    Thread Starter ninetienne

    (@ninetienne)

    I’m sorry, but I can’t figure it out. Your updated plugin still creates several attachments for the same thumbnail image.

    Here’s my test csv. After the import there should be only two new attachments in the media library.

    Could you please give a direction how I can attach the same image to several imported posts.

    Plugin Author Takuro Hishikawa

    (@hissy)

    > After updating the plugin I get an error: Parse error: syntax error, unexpected T_PAAMAYIM_NEKUDOTAYIM in \wp-content\plugins\really-simple-csv-importer\rs-csv-importer.php on line 350

    Sorry, this is a bug when running on PHP5.2, and I’ve updated to fix it.

    > how I can attach the same image to several imported posts.

    First, upload image via media upload in dashboard, then check that attachment id, and write plugin to override save_post method and manually attach media to each posts like as my gist code.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Check if the attachment already exists’ is closed to new replies.