Can’t upload media, permissions are correct
I found the problem. In settings > media the folder for uploads was actually pointing to a different path. Once I redirected it to wp-content/uploads it all worked.
I found the problem. In settings > media the folder for uploads was actually pointing to a different path. Once I redirected it to wp-content/uploads it all worked.
This block of code will add a button right next to the “Insert into post” one. When clicked, it will send selected images to WP editor, each wrapped inside your template HTML: var wpMediaFramePost = wp.media.view.MediaFrame.Post; wp.media.view.MediaFrame.Post = wpMediaFramePost.extend( { mainInsertToolbar: function( view ) { “use strict”; wpMediaFramePost.prototype.mainInsertToolbar.call(this, view); var controller = this; this.selectionStatusToolbar( view … Read more
In a previous tinymce plugin I made – I set up a custom ajax transport so I could just use the blob right from the image src of a remote img instead of base64 on a data attribute, and then used the REST API to upload the image to the media library in js. Base64 … Read more
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
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
This works for me in order to list the items uploaded by a user on the media library. function users_my_media_only( $wp_query ) { if ( false !== strpos( $_SERVER[ ‘REQUEST_URI’ ], ‘/wp-admin/upload.php’ ) ) { $current_user = wp_get_current_user(); $current_user = $current_user->ID; if ( ! current_user_can( ‘manage_options’ ) ) { global $current_user; $wp_query->set( ‘author’, $current_user->id ); … Read more
Here’s how I recently added a custom taxonomy to the media library as a sortable column: // Add a new column add_filter(‘manage_media_columns’, ‘add_topic_column’); function add_topic_column($posts_columns) { $posts_columns[‘att_topic’] = _x(‘Topic’, ‘column name’); return $posts_columns; } // Register the column as sortable function topic_column_register_sortable( $columns ) { $columns[‘att_topic’] = ‘att_topic’; return $columns; } add_filter( ‘manage_upload_sortable_columns’, ‘topic_column_register_sortable’ ); … Read more
This is due to the PHP limitations on file size uploads. If you have access to your php.ini file, you can modify the following lines: upload_max_filesize = 10M post_max_size = 10M max_execution_time = 300 If you don’t have access to the php.ini file (such as a hosting situation), you may need to contact your webhost … Read more
Only Uploader below a example code, works only on post edit page. If you will use also on other page, then include the function wp_enqueue_media(), see the next headline. jQuery(document).ready(function($) { var _custom_media = true, _orig_send_attachment = wp.media.editor.send.attachment; $(‘.stag-metabox-table .button’).click(function(e) { var send_attachment_bkp = wp.media.editor.send.attachment; var button = $(this); var id = button.attr(‘id’).replace(‘_button’, ”); _custom_media … Read more
W3-Total Cache has a feature that will scan all your posts and import any external images into the media library and change the paths to the new location. See Screenshot