Uploading media with the REST API

This is not possible via the API; you need to fetch the image yourself, and send the data to the API yourself. Blockquote – This quotes Ryan on the GitHub–issue mentioned in @Dan (deleted) answer. How to side load images Note that the media_sideload_image() return value can be an instance of \WP_Error as well. You … Read more

Use a separate upload folder for custom post attachment upload

I ended up solving it by completely bypassing the wp upload system, so this is how it looks now: /* * Define new upload paths */ $uploadfolder = WP_CONTENT_DIR . ‘/exames’; // Determine the server path to upload files $uploadurl = content_url() . ‘/exames/’; // Determine the absolute url to upload files define(RM_UPLOADDIR, $uploadfolder); define(RM_UPLOADURL, … Read more

How to add a custom field to the media screen (image/gallery)?

Here is the working code (working fine for me), did you tried this? Just add to theme ‘functions.php’ and change the custom field names as needed. //function to add custom media field function custom_media_add_media_custom_field( $form_fields, $post ) { $field_value = get_post_meta( $post->ID, ‘custom_media_style’, true ); $form_fields[‘custom_media_style’] = array( ‘value’ => $field_value ? $field_value : ”, … Read more

Which asset URLs are acceptable in a “vanilla” MU install?

Short Answer example.com/bob/files/picture.jpg is the preferred, canonical URL for images in a WordPress Multisite installation. The two URLs with blogs.dir in the URL are essentially identical, and both leverage the filesystem structure. The path with ‘bob’ exists because you did a sub-directory install, not a subdomain install. Other paths would exist based on your other … Read more

How to change upload directory in wp_handle_upload

Here’s a complete example for how we do it in Easy Digital Downloads: /** * Set Upload Directory * * Sets the upload dir to edd. This function is called from * edd_change_downloads_upload_dir() * * @since 1.0 * @return array Upload directory information */ function edd_set_upload_dir( $upload ) { $upload[‘subdir’] = ‘/edd’ . $upload[‘subdir’]; $upload[‘path’] … Read more

Give users a maximum upload capacity; limit the number of files a user can upload OR limit the number of files per upload

Assuming that you’re providing upload functionality via WordPress’ native functions, lik wp_handle_upload or something more high-level, we come to the conclusion that several hooks are going to be pulled. http://core.trac.wordpress.org/browser/tags/3.3/wp-admin/includes/file.php#L212 The wp_handle_upload function would probably be the last native function to touch the file, and would know all the information that is necessary to keep … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)