• Dear Sir,

    I am studying your code because I am trying to modify it to fit my needs. Some comments if I may, in order for me to know that I am in the right path.
    On line 427 there is this line:
    $file = media_sideload_image( $img, (int)$post->ID );
    This line of code is executed when the option ‘Set Featured Images’ of the plugin is set. In most cases this means that the image sources that appear inside posts are not external but rather live in the same server as the post (namely they are not external). Under this assumption, the code normally it should extract the url from the post’s content and then do something like:

    wp_insert_attachment($attachment, $file, $post_id);
    wp_update_attachment_metadata( $id, wp_generate_attachment_metadata( $id, $file ) );

    Instead in this case the media_sideload_image() function tries to re-upload the image back into the server and in many cases (for example if it tries in the same directory) it fails.
    Maybe it should check if the image is local or external and then decide what to do.

    What do you think ? Your feedback is important to me

    Many thanks for your time
    ioannis

    http://ww.wp.xz.cn/extend/plugins/media-tools/

The topic ‘Code improvement/correction ?’ is closed to new replies.