WordPress.org

Ready to get started?Download WordPress

Forums

Auto Save Remote Image
[resolved] Doesn't handle % characters correctly (4 posts)

  1. etchedinpixels
    Member
    Posted 1 year ago #

    Hi, great idea for a plugin.

    However, I'm having some problems using it with my Smugmug hosted images due to the way it translates % symbols in the URL.

    Here's what happens. I insert an image

    http://etchedinpixels.smugmug.com/Things/Still-Life/i-WrrB5bg/3/M/Giant%20peach%20moktak%3F-M.jpg

    And the plugin uploads it to my site as

    http://etchedinpixels.com/blog/wp-content/uploads/2012/11/Giantpeachmoktak%3F-M.jpg

    However, WordPress then fails to load the image, it returns a 404.

    I found that the URL needs to be entered as

    http://etchedinpixels.com/blog/wp-content/uploads/2012/11/Giantpeachmoktak%253F-M.jpg

    Note that in the browser any % in the filename needs to be changed to %25 the plugin isn't doing this when inserting the URL into the post.

    I'm going to see what I can do to fix the code but I barely know anything. I'll post if I have a solution. Thanks for all the great work.

    http://wordpress.org/extend/plugins/auto-save-remote-images/

  2. prebhdevsingh
    Member
    Plugin Author

    Posted 1 year ago #

    Hi there,

    I will try to fix this bug and update the plugin soon. Thanks for pointing it out.

    Regards,
    PS

  3. etchedinpixels
    Member
    Posted 1 year ago #

    Thanks!

    I don't know much about php but after talking with my developer friend, he suggested the URLDECODE function to convert the image filename before copying it on one's WordPress site.

    It now seems to handle the %3F symbol in my smugmug image correctly.
    It takes the image URL
    http://etchedinpixels.smugmug.com/Things/Still-Life/i-WrrB5bg/3/M/Giant%20peach%20moktak%3F-M.jpg

    and stores the file locally as Giantpeachmoktak-M.jpg

    It would be nice if it also converted the %20 to '_' . But the main thing is that it seemed to handle the question mark (encoded as %3F) correctly.

    I replaced:

    $mirror = wp_upload_bits( str_replace('%20', '', basename( $first_image )), '', wp_remote_retrieve_body( $get ) );

    with

    $mirror = wp_upload_bits( urldecode(basename( $first_image )), '', wp_remote_retrieve_body( $get ) );

    Prebhdev, would you mind telling me if I implemented this correctly and it's working for you too?

  4. prebhdevsingh
    Member
    Plugin Author

    Posted 1 year ago #

    Hi there,

    Your friend is correct. I have uploaded new copy of the plugin which fixes this issue. Instead of using urldecode, I'm instead using rawurldecode. This should take care of the problem with % signs in filenames.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.