Created
February 6, 2012 18:55
-
-
Save jluster/1754061 to your computer and use it in GitHub Desktop.
Dropkick plugin to rewrite URLs to Dropbox from local wp-content
This file contains hidden or 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://feastcraft.com/3629/solving-the-image-storage-question | |
* Description: Rewrite local image locations to dropbox locations | |
* Version: 0.2 | |
* Author: Jonas M Luster <[email protected]> | |
* Author URI: http://feastcraft.com | |
* License: GPL3 | |
* */ | |
$DK_MY_DROPBOX_ID = ""; | |
$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; | |
} | |
# and here we handle NextGen Images. See the comments for an explanation, this needs a little (not much) work. | |
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