Skip to content

Instantly share code, notes, and snippets.

@mkdizajn
Created December 11, 2012 11:09
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save mkdizajn/4257824 to your computer and use it in GitHub Desktop.
Save mkdizajn/4257824 to your computer and use it in GitHub Desktop.
wordpress plugin rewrite media path
<?php
/*
Plugin Name: Rewrite Wordpress upload path
Plugin URI: http://mkdizajn.com
Description: Rewrites your image paths.
Version: 2.4
Author: kreso
Author URI: http://mkdizajn.com/
*/
function rewrite_url($rewrite)
{
$rewrite = str_replace('yoursite.com/wp-content/uploads/', 'media.yoursite.com/wp-content/uploads/', $rewrite);
return $rewrite;
}
add_filter('wp_get_attachment_url', 'rewrite_url');
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment