Wordpress Plugin: Post, Upload and Paste

November 15th, 2005

UPDATE [5/13/06]: a new version of this plugin supports Wordpress 2.
Check it out it here.

As part of a still-underground project of mine, I am putting together a site using Wordpress 1.5. Something struck me pretty quickly though: there is no way for a user to upload a photo and paste it into a new or current post, not all in the same step.

Curent steps?

  1. Go to “Upload” tab
  2. Pick a file, then upload it
  3. Copy the HTML code that WordPress spits out
  4. Create a post, or find the post you want to edit
  5. Go to the spot where you want to paste it.

Barf.

Problem #1: that code may not be in the in the clipboard by the time you click through.
Problem #2: if you chose to create a thumbnail? Wordpress won’t say where it is, or what it named it.
Problem #3: no preview.

I like Wordpress exactly because it’s modular enough to add functionality with a plugin. Seems like this is the perfect opportunity for one, so I set about creating a plugin to solve all three problems.

First step was to create the page to handle it. That didn’t turn out to be a problem, as I copied and hacked the original upload page.

My other problem was addding a button to the post screen for uploads. Googling around, I found a lot of the work had been done on this. Awesome.

Long story short, here it is. Download at your own risk.

Post, Upload, and Paste Plugin for Wordpress 1.5

INSTRUCTIONS:

  1. Unzip in the /wp-content/plugins directory.
  2. Change permissions on the pup folder contents (644 744 is fine) – corrected from comments below
  3. Move upload_popup.php to the /wp-admin directory.
  4. Activate your plugin!

Big thanks to the Tech Wench for solving half my problem (how to add the button to the post screen). The only downside is that the button there only works on IE and Firefox. (Ironic, since I’m a Mac junkie.) If someone’s got a better solution out there feel free to let me know here (comments below), via email (rem at alum daught mit daught edu), or steal my code and hack away. Whichever.

Entry Filed under: default

12 Comments

  • 1. Bom Garfo  |  November 16th, 2005 at 4:55 am

    An error shwed up at admin panel:

    Warning: file(/wp-content/plugins/pup/post-upload-and-paste.php): failed to open stream: Permission denied in /wp-admin/admin-functions.php on line 962

    Warning: implode(): Bad arguments. in /wp-admin/admin-functions.php on line 962

  • 2. ruben  |  November 17th, 2005 at 3:18 pm

    Did you set the permissions on both files to 644?

  • 3. ruben  |  November 17th, 2005 at 4:42 pm

    Also, what version of WP are you using? I developed it on 1.5.2, but am willing to test against different versions.

  • 4. Unixoid  |  November 21st, 2005 at 4:33 pm

    This is an excellent plugin. Very handy. A brief remark regarding the error mentioned above: the “Permission denied” issue can be fixed by making post-upload-and-paste.php executable by the account under which the Web server is running.

    Example: if apache is running under wwwrun, do chown wwwrun post-upload-and-paste.php and chmod 744 post-upload-and-paste.php

    This file needs to be executable, so I don’t think that 644 would be enough.

  • 5. Night Soul  |  November 24th, 2005 at 12:42 am

    I’m impressed.. I was looking for exactly this sort of thing and even though I had problems I had to figure it out and it was very easy.

    I’ll put all the things I figured out so other people know they need to do these things.

    1. the upload function must be enabled.

    2. forget using the “pup” folder. it didn’t work whether or not I chmodded it. Just put the file in the plugins folder.

    3. make sure both files are chmodded to be writable and executable.

    That’s it… Thank you for this plugin, it saved me a lot of scripting time.

  • 6. ruben  |  December 19th, 2005 at 12:09 pm

    Thanks to everyone for the helpful suggestions. I will do my best to resolve the bugfixes mentioned, including removing the subfolder altogether and fixing the link path to work with subfolders (as seen here).

    I also know WP 2.0 is around the corner, with a new WYSIWYG edit screen, but as of Release Candidate 1 their approach is decidedly lacking (in other words, not as elegant as this plugin). I would love to fork this plugin for WP 2.0, but I don’t really know TinyMCE all that well (WP’s rich text editor of choice). Stay tuned.

  • 7. Luitzen  |  March 10th, 2006 at 5:07 am

    When i push the upload button, the popup appears, and it says : “The admin disabled this function”.
    How can i enable ?

  • 8. ruben  |  March 14th, 2006 at 2:11 pm

    Assuming you’re using WP 1.5, you need to have the uploading feature enabled. Look for it under the “Options” tab.

  • 9. Gilbert  |  May 10th, 2006 at 1:53 pm

    Ruben,

    Does your plug in work with WP 2.0?

  • 10. ruben  |  May 13th, 2006 at 12:59 am

    This one doesn’t, but I’ve branched the plugin so it now supports WP2. You can get it here.

  • 11. Jaylin  |  December 12th, 2006 at 3:06 pm

    What I want to do on my blog, is every few hours take the oldest post and move it to the
    front of the queue, all automatically. Anyone know if there is a plugin that can do this or
    a simple way to set up another plugin to do this (use my own feed perhaps)?
    Thanks.

  • 12. Joe  |  February 2nd, 2007 at 7:09 pm

    Great work — much appreciated!


About

I'm Ruben Miranda. I'm an MBA student graduate and financial services advisor living in Austin, Texas. This is my blog, home to some random takes on finance, business, software, and occasionally pop culture. Thanks for stopping by. (By the way, I don't speak for my employer.)

rem@alum.mit.edu

Networks

Social Networkage
linkedin.com/in/rubenmiranda

Previous

Archive