Fatal Error Call To Undefined Function Download_url
Contents |
tour help Tour Start here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and
Media_handle_sideload
policies of this site About Us Learn more about Stack Overflow the media_sideload_image get attachment id company Business Learn more about hiring developers or posting ads with us WordPress Development Questions Tags Users Badges Unanswered
Wordpress Media_sideload_image
Ask Question _ WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute: Sign up Here's how it works: Anybody can ask a question Anybody can answer The best answers are voted up and rise to the top How to add a media with PHP up vote 2 down vote favorite 2 I have more than 1000 pictures on my webserver, uploaded with FTP in a local folder ( /home/chris/pictures ) Is there a way to add them as a well known media to wordpress in PHP and get their id? while ( $the_query->have_posts() ) : $the_query->the_post(); $post_id = get_the_ID(); $filemakerID = get_post_meta($post_id, 'filemaker_id', true); $file['url']='/home/chris/picture_export/'.$filemakerID.'.jpeg'; $file['type'] = 'image/jpeg'; //THE DREAMED FUNCTION WOULD BE USED THIS WAY $photo_id = awesome_function( $file, $post_id); add_post_meta($post_id, 'photo', $photo_id ); } As you noticed, my photo is used in a custom field photo as well. After hours on google dans codex, I noticed how poorly documented these functions are. Maybe I just could not figure out the correct keywords to search. images uploads media share|improve this question edited Aug 16 '12 at 7:30 asked Aug 16 '12 at 7:21 Christian 272418 add a comment| 1 Answer 1 active oldest votes up vote 5 down vote accepted If I'm understanding correctly, each post has a filemaker, and each filemaker has only one photo? The structure is kind of unclear. Anyways, one way is top use media_sideload_image like below. However, media_sideload_image WON'T work with local files (a path on your filesystem), so you need to change your $file['url'] to be a valid URL (http://yourhomepage.com/chris/pictures, for example). If you
undefined function download_url() [Resolved] Fatal error: Call to undefined function download_url() DrMosko @drmosko 8 months, 3 weeks ago Fatal error: Call to undefined function download_url() in http://wordpress.stackexchange.com/questions/61979/how-to-add-a-media-with-php public_html/wp-content/plugins/wp-shabbat/wp-shabbat-update.php on line 15 we working on it https://wordpress.org/plugins/wp-shabbat/ Viewing 1 replies (of 1 total) Plugin Author DrMosko @drmosko 8 months, 3 weeks ago the isuue has https://wordpress.org/support/topic/fatal-error-call-to-undefined-function-download_url-1/ been fixed in version 2.0 Viewing 1 replies (of 1 total) You must be logged in to reply to this topic. About this Plugin WP-Shabbat Support Threads Reviews Topic Info In: Plugins and Hacks 1 reply 1 participant Last reply from: DrMosko Last activity: 8 months, 3 weeks ago Status: resolved Forum Search Search for: About Blog Hosting Jobs Support Developers Get Involved Learn Showcase Plugins Themes Ideas WordCamp WordPress.TV BuddyPress bbPress WordPress.com Matt Privacy License / GPLv2 Code is Poetry.
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta http://stackoverflow.com/questions/32934364/media-sideload-image-gets-fatal-error-call-to-undefined-function-wp-get-current Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, fatal error helping each other. Join them; it only takes a minute: Sign up media_sideload_image gets fatal error Call to undefined function wp_get_current_user() in C:\xampp\htdocs\project-name\wp-includes\capabilities.php up vote 0 down vote favorite Trying to implement media_sideload_image() for the first time from a plugin and getting an error: Fatal error: Call to undefined function wp_get_current_user() in C:\xampp\htdocs\project-name\wp-includes\capabilities.php on line 1441 This fatal error call is the PHP I am using: require_once( ABSPATH . '/wp-admin/includes\plugin.php'); require_once( ABSPATH . '/wp-admin/includes\media.php'); require_once( ABSPATH . '/wp-admin/includes\file.php'); require_once( ABSPATH . '/wp-admin/includes\image.php'); $url = "http://wordpress.org/about/images/logos/wordpress-logo-stacked-rgb.png"; $post_id = 1; $desc = "The WordPress Logo"; $image = media_sideload_image($url, $post_id, $desc); As you can see this is the code from the Wordpress Codex with a bit of addition from forums after I got other errors. However, without luck. Obviously there is something wrong with the codex code or maybe it's not meant to be used in plugins(?) What I'm eventually trying to do is get an image and add it to the media library and into the post being edited \ added directly. I'd appreciate any help I can get. Thanks php wordpress-plugin wordpress share|improve this question asked Oct 4 '15 at 14:11 Avi 96210 add a comment| 1 Answer 1 active oldest votes up vote 1 down vote If it could help, jsut have the same problems, solved by adding this line : if(!function_exists('wp_get_current_user')) { include(ABSPATH . "wp-includes/pluggable.php"); } share|improve this answe