0

I currently use Press This to reblog posts from mainly Vimeo but other times I just want to quote pieces of articles that I can add my own words to. The output Press This gives is mainly just the title twice; once as the title and the second this as the source.

So basically I want Press This to insert the [vimeo] short tag instead of <object> tags. And for selecting text, it would be great if I could find a way to use quotation marks for the sourced paragraph.

So like this for a TechCrunch post : Facebook Preparing To Announce 500 Million Users


Facebook is about to announce that they’ve hit 500 million users — a milestone that cements (as if it hadn’t already) the site’s status as one of the web’s biggest successes ever. Of course, at Facebook’s growth trajectory it hasn’t been a matter of if the social network would be hitting 500 million, but when it would (in fact, the movie poster for the upcoming movie The Social Network uses the 500 million stat in its tagline). Still, it’s finally about to become official. So how do we know?

via TechCrunch


This is a wordpress.com account, I apologize for not stating this earlier.

Retaining format/links would be a plus.

Here is the Press This that is used as a bookmarklet.

1 Answer 1

1

I addressed your Vimeo question and will let you or someone else cover the quotation marks questions (since I didn't understand that part of your question.)

PressThis uses JavaScript to capture the information about the Vimeo video. In order to modify it you need to hook WordPress in one of the few places you can hook it in PressThis and insert your own JavaScript code, and I chose to hook the "admin_print_footer_scripts" action.

In the JavaScript code generated by the hook I set a timer and continued to check the #embed-code textarea every 100 milliseconds until it had a non-null value, and then I disabled the timer (I might have been able to do it without a time but I couldn't figure it out.)

One I had a valid value to operate on I used a regular expressions to extract the clip ID. I coded it so that you can select multiple videos and it will copy all of them (assuming that PressThis even supports it.) The looping on i+=2 allows the code to grab the clip_id for the <object> tag and ignore the <embed> tag. The height and width are hardcoded; you can easily change them in the code if you like.

That's about it. Here's the code to copy into your WordPress theme's function file, or use it to create a plugin (you can also find the code here: http://gist.github.com/478078):

add_action('admin_print_footer_scripts','greatjakes_admin_print_footer_scripts');
function greatjakes_admin_print_footer_scripts() {
    if ($_SERVER['PHP_SELF']=='/wp-admin/press-this.php') {
        $script=<<<SCRIPT
<script type="text/javascript">     
    var intervalId;
    var embedCode;
    function monitorEmbedCode() {
        embedCode = jQuery("#embed-code").val();
        if (embedCode!=null) {
            window.clearInterval(intervalId);
            var matches = embedCode.match(/clip_id=([0-9]+)&/g);
            var output = '';
            var clipId = 0;
            for (var i=0; i<matches.length; i+=2 ) {
                clipId = parseInt(matches[i].replace(/(.+=)([0-9]+)(&)/,'$2'));
                output += '[vimeo clip_id="' + clipId + '" width="400" height="225"]\\n';
            }
            jQuery("#embed-code").val(output);
        }
    }
    intervalId = window.setInterval(monitorEmbedCode,100);
</script>
SCRIPT;
        echo $script;
    }
}

Hope this helps.

3
  • +1 Thanks for the hack , unfortunately I am talking about a wordpress.com account. I updated the question with the javascript that is used for the PressThis bookmark.So is this method possible to use without going in the admin code ?
    – phwd
    Jul 16, 2010 at 10:31
  • Unless there is something obscure that I don't know about, you can't do this kind of thing on WordPress.com. Time to get yourself a self-hosted WordPress? Aug 12, 2010 at 21:14
  • Yeah I do have a self-hosted as well. Trying to push the limits of the wordpress.com one. Right now it involves lengthy chats with customer support. Thanks again.
    – phwd
    Aug 22, 2010 at 11:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.