Skip to content

Instantly share code, notes, and snippets.

@jluster
Created June 24, 2012 03:55
Show Gist options
  • Save jluster/2981510 to your computer and use it in GitHub Desktop.
Save jluster/2981510 to your computer and use it in GitHub Desktop.
<?php
/*
* Plugin Name: dropkick
* Plugin URI: http://d8c.us/
* Description: Rewrite local image locations to dropbox locations
* Version: 0.2
* Author: Jonas M Luster <j@d8c.us>
* Author URI: http://feastcraft.com
* License: GPL3
* */
$DK_MY_DROPBOX_ID = "2600509";
$DK_MY_DROPBOX_FOLDER = "/fc-uploads/";
$DK_MY_STRIPPER = "/wp-content/uploads/";
add_filter('the_content', 'dropkickr');
add_filter('post_gallery', 'dropkickr');
add_filter('ngg_image_object', 'ngg_dropkickr_image_object');
function dropkickr($content) {
global $wp_query;
global $DK_MY_DROPBOX_ID;
global $DK_MY_DROPBOX_FOLDER;
global $DK_MY_STRIPPER;
$site = get_option('siteurl');
$dropbox = "http://dl.dropbox.com/u/".$DK_MY_DROPBOX_ID.$DK_MY_DROPBOX_FOLDER;
$content = preg_replace(
'~'.$site.$DK_MY_STRIPPER.'~i',
$dropbox,
$content);
return $content;
}
function ngg_dropkickr_image_object($object)
{
$object->thumbURL = dropkickr($object->thumbURL);
$object->thumbnailURL = dropkickr($object->thumbnailURL);
$object->imageURL = dropkickr($object->imageURL);
return $object;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment