Created
June 24, 2012 03:55
-
-
Save jluster/2981510 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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