Support » Plugin: Auto Post Thumbnail » [Plugin: Auto Post Thumbnail] Duplicating images when using Mars Edit 3 on Mac

  • I’m still testing Mars Edit for a ‘magazine style’ photoblog (on a self hosted WordPress site) and using WP’s ‘post-thumbnails’ feature to create and display a thumbnail image on the main page (index.php) for each post.

    To automate the production of the thumbnail, I use the ‘Auto Post Thumbnail’ plugin which creates the thumbnail from the first image in the post.

    This works perfectly if I use the login to the WP control panel on the site, but when I use ME, I get duplicates of both the original file and the thumbnail.

    For example: (in the WP Uploads folder)



    There is obviously some conflict between the plugin and MarsEdit, but I’m at a loss as to what it could be?

    Confused! 8^.


    [I posted this on the Mars Edit support pages here:

    and received this advice, but I have no idea if this could be the case.. can anyone help?

    I’ve had this problem when WordPress didn’t have enough memory to upload an image. Sometimes when you are just on the edge, I had to upload twice and you get two images.

    My _guess_ is that the upload works fine, but then a PHP process that creates the resized image exceeds the memory causes a failure in the XML-RPC process due to insufficient RAM in PHP but the upload has worked just fine.

    I’ve since changed my wordpress configuration to allocate 64M and now 96M so that I can reliably upload images – in my case, I also run them through with a plugin to reduce image size.


Viewing 3 replies - 1 through 3 (of 3 total)
  • Hi Barry,

    Do you mean that when you create a post through wordpress then the image 300×240 is not generated by auto post thumbnail? I think the second image must get created since the featured image is nothing but a thumbnail’ed version of your original image and it will generate images of different sizes that you have configured.

    So IMO, seeing multiple images is a perfectly normal behavior.

    Let me know if you were expecting something else.


    Hi Aditya,

    Thank you for your reply.

    I think you misunderstand my problem?

    I know that multiple images is normal behaviour; (1 ‘original’ image and 1 ‘featured or thumbnail’ image) (or more, if you configure for different thumb sizes)

    What I am experiencing is duplication of the ‘original’ image and the ‘thumb image’ so I end up with 4 instead of only 2.

    Please, look at my post above again.

    The example:


    is what should be happening.. (and this happens when I use the WP dashboard to post to WP)



    is what is happening when I use the blog editing program Mars Edit to post images and text to WP.

    I posted my problem on the Mars Edit forum, but they suggested I contact you as the writer of the plugin;

    In situations like this it’s extremely likely to be an issue in the plugin, and not in MarsEdit. This is because MarsEdit has very limited access to your blog’s media storage (i.e. it has zero access :)).

    When you upload an image with MarsEdit to your blog, it’s just requesting to the blog system that it accept the file and save it in the media folder. If it’s creating multiple files it has to be an issue on the server side. If it’s only happening when this plugin is enabled, then it’s probably something to follow up with the plugin developer about.

    Sadly, I’m not a programmer so I can’t begin to think where the conflict lies but does any of the above make sense to you?

    One thing I wonder, does your plugin require the feature to be turned on in the ‘functions.php’ file? I added this as per the link on the plugin site;

    add_theme_support( ‘post-thumbnails’, array( ‘post’ ) ); // Add it for posts
    set_post_thumbnail_size( 300, 240, true ); // 300 pixels wide by 240 pixels tall, hard crop mode

    This would not cause the duplication would it?

    Any help you can give would be gratefully received.. this plugin is just what I need if only I can get it to work with MarsEdit!!




    I’m pretty sure the problem is in the function apt_publish_post of auto-post-thumbnail.php. Firstly, the plugin searches for all image tags with preg_match_all, using a capture group to grab the contents of the “src” attribute. But then on line 256 the plugin looks at “$matches[0]” for the src attribute value, when it should be “$matches[1]” (with regular expression references, 0 is the entire match, and 1 and upwards refers to the capture groups).

    Then, on line 266, the plugin strips anything from $image before a double-quote character – this may be a legacy statement:

    $image = substr($image, strpos($image, '"')+1);

    However, as “$image” is the image URL (or should be, if the correct regular expression reference were being used), all this does is strip the first character, leaving $image as something like “ttp://”.

    Consequently, no image is ever picked up from the DB, and the plugin will duplicate the image.

    So, change $matches[0] to $matches[1] on line 256, and get rid of the ‘substr’ statement on line 266, and it should work.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘[Plugin: Auto Post Thumbnail] Duplicating images when using Mars Edit 3 on Mac’ is closed to new replies.