All the wordpress functions for retrieving media details seem to give you the web url of a file uploaded. I want to the local server drive/folder path, ideally relative to the install of wordpress. I have the attachment id value to hand so can parse that to a function, if only I knew what it was.
Is this possible with a function built in that I’ve missed? If not does anyone have anything pre-written for this function?
get_attached_file returns the server path of an attachment.
You can use the ‘wp_upload_dir()’ function to get an array of all the path information of the currently configured uploads directory.
$upload_dir = wp_upload_dir(); echo $upload_dir['path'];