File Upload from Frontend

Before Header: <?php $post_id = $post->ID; if ( isset( $_POST[‘html-upload’] ) && ! empty( $_FILES ) ) { require_once( ABSPATH . ‘wp-admin/includes/admin.php’ ); $id = media_handle_upload( ‘async-upload’, $post_id ); //post id of Client Files page unset( $_FILES ); if( is_wp_error( $id ) ) { $errors[‘upload_error’] = $id; $id = false; } if( $errors ) { … Read more

HTTP Error When Uploading Images with HTTPS?

Adding this to my theme’s functions.php solved this same problem for me: add_filter( ‘wp_image_editors’, ‘change_graphic_lib’ ); function change_graphic_lib($array) { return array( ‘WP_Image_Editor_GD’, ‘WP_Image_Editor_Imagick’ ); }

Restrict role to view own media

You can restrict users to seeing only their own uploaded media with this piece of code: <?php /* Plugin Name: Manage Your Media Only Version: 0.1 */ //Manage Your Media Only function mymo_parse_query_useronly( $wp_query ) { if ( strpos( $_SERVER[ ‘REQUEST_URI’ ], ‘/wp-admin/upload.php’ ) !== false ) { if ( !current_user_can( ‘level_5’ ) ) { … Read more

Original image not saving?

The default image sizes of WordPress are “thumbnail”, “medium”, “large” and “full” (the size of the image you uploaded). These image sizes can be configured in the WordPress Administration Media panel under Settings > Media. This is how you can use these default sizes with the_post_thumbnail(): the_post_thumbnail(); // without parameter -> ‘post-thumbnail’ the_post_thumbnail( ‘thumbnail’ ); … Read more

WordPress Drag n Drop Uploader – Single File Only

Kind of hard without understanding how you are arriving to a plugin for editing, but perhaps the user should have the option to choose which file they wish to edit instead of this automatically happening. Similar to how you “choose” which image you want to use as a featured image, for example. This way multiple … Read more

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