media_sideload_image (3 posts)

  1. alex2k5
    Posted 2 years ago #

    I am looking to run a stand alone file, one time, to attach images from an old non-WP system.

    I have the ability to run:

    require_once(ABSPATH . 'wp-admin/includes/media.php');
    require_once(ABSPATH . 'wp-admin/includes/file.php');
    require_once(ABSPATH . 'wp-admin/includes/image.php');
    $image_result = media_sideload_image($images_url, $post_id);
    echo '<pre>'; var_dump($image_result);

    for each image.

    However, I need to know what to specify to ensure that it's reading and inserting into the proper multisite tables. AKA site1, site2, site4, etc etc.

    Any help appreciated.

  2. krembo99
    Posted 2 years ago #

    Make a plugin and activate on a specific blog ..
    Or : INCLUDE in a theme that is activated only on the intended blog .

    the second method is risky if the blog is alive , because it will get executed whenever accessed . but I had made it before and it is ok .

  3. OR put it in mu-plugins and wrap it with a check for 'If this is site X...' :)

Topic Closed

This topic has been closed to new replies.

About this Topic