Skip to content

Instantly share code, notes, and snippets.

@emersonbroga
Created April 24, 2012 19:03
Show Gist options
  • Save emersonbroga/2482748 to your computer and use it in GitHub Desktop.
Save emersonbroga/2482748 to your computer and use it in GitHub Desktop.
Get Image Path from Wordpress Image URL
<?php
defined('UPLOAD_PATH') || define('UPLOAD_PATH', 'path_to_wp-content_uploads');
$url = 'image_URL'; //Image url like http://www.site.com/wp-content/uploads/year/month/image.jpg
$parts = array_slice(explode('/', $url), -3);
$imagePath = UPLOAD_PATH . implode(DIRECTORY_SEPARATOR, $parts);
if(file_exists($imagePath))
{
$info = getimagesize($imagePath);
echo '<pre style="background-color: #FFF; color:#000">';
var_dump($info);
echo '</pre>';
}
die();
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment