Benefits of storing uploads in an assets folder?

The only directory a theme or a plugin should write to is the uploads directory. That is the only directory with guaranteed write access (besides the server’s temporary directory). Anything else is wrong and might not work. There is no practical difference between both, except one: the upload directory may be on another (sub) domain … Read more

Debugging upload problem: What part of WP does actual image-resizing?

You can add a filter to wp_image_editors and see what editor is in use (GD or Imagick). In a past project I’ve extended the resize routines on both GD, and Imagick, and the methods responsible for resize are WP_Image_Editor_Imagick->crop() and WP_Image_Editor_GD->_resize(). Note that WP_Image_Editor_GD->resize() is just a wrapper. The process it’s run on ajax, but … Read more

Alter media caption/description conflict in WordPress?

I wonder if this will work for you: add_action( ‘add_attachment’, function( $attachment_id ){ $a = get_post( $attachment_id ); if ( is_object( $a ) && ‘image’ === substr( $a->post_mime_type, 0, 5 ) ) wp_insert_attachment( array( ‘ID’ => $a->ID, ‘post_excerpt’ => $a->post_content ) ); }); or with less queries: add_action( ‘add_attachment’, function( $attachment_id ){ global $wpdb; if( … Read more

How to limit file type to be upload?

This is a full working example with file type and size limits and all the error handling. Every step is commented. Let me know if you have any more questions. You can find all the mime types from here. Make sure to check if it’s allowed in WP too. // Allowed file types -> search … Read more

How do i upload an image and return the image id?

Take a look at side loading images. media_sideload_image()/wp_handle_sideload() and get the ID from the URL. attachment_url_to_postid. <?php $url = “http://wordpress.org/about/images/logos/wordpress-logo-stacked-rgb.png”; $title = “Some Image Title”; $alt_text = “Some Alt Text”; require_once(ABSPATH . ‘wp-admin/includes/media.php’); require_once(ABSPATH . ‘wp-admin/includes/file.php’); require_once(ABSPATH . ‘wp-admin/includes/image.php’); // sideload the image — requires the files above to work correctly $src = media_sideload_image( $url, … Read more

custom tabs in media uploader

found it. in the automattic SVN for media.php i found the media_upload_header() function, and the only thing left to do is to echo it in the last function: function media_upload_ell_gmap_form() { echo media_upload_header(); ?> <h2>HTML Form</h2> <?php } that’s it.

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