Media library to list images only user uploaded

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

Custom post type with a forced fixed aspect ratio image crop

Don, You will have to add support for thumbnails in your functions.php/plugin-file.php //Add Support for Thumbs if ( function_exists( ‘add_theme_support’ ) ) { add_theme_support( ‘post-thumbnails’ ); set_post_thumbnail_size( 960, 276, true ); // default Post Thumbnail dimensions } //Add Thumbnail sizes if ( function_exists( ‘add_image_size’ ) ) { add_image_size( ‘large-thumb’, 960, 276, true ); //960 pixels … Read more

How can you set maximum width for original images?

I was able to solve it using the following code: function my_handle_upload ( $params ) { $filePath = $params[‘file’]; if ( (!is_wp_error($params)) && file_exists($filePath) && in_array($params[‘type’], array(‘image/png’,’image/gif’,’image/jpeg’))) { $quality = 90; list($largeWidth, $largeHeight) = array( get_option( ‘large_size_w’ ), get_option( ‘large_size_h’ ) ); list($oldWidth, $oldHeight) = getimagesize( $filePath ); list($newWidth, $newHeight) = wp_constrain_dimensions( $oldWidth, $oldHeight, $largeWidth, … Read more

Add media with WP-Rest-API v2

SO! This is fun. Keep in mind the WP-API is still very, very much a work-in-progress. Content-Disposition I found an issue reported on the WP-API issue queue about Content-Disposition. This is a required header for posting new media content and there are some very, very strict requirements when it comes to providing this in the … Read more

Update media library files after upload via FTP

Avoid direct upload WordPress doesn’t scan upload directory for new files, instead use WordPress media uploader to add files WordPress automatically creates folder and store them accordingly. But you can use this plugin to import those uploaded files into WordPress, it should help you https://wordpress.org/plugins/add-from-server/

For what security reasons are svgs blocked in the media uploader?

SVG can contain JavaScript. JavaScript can be used to hijack cookies or do other questionable actions. It can even be “hidden” in namespaces: <html xmlns:ø=”http://www.w3.org/1999/xhtml”> <ø:script src=”https://0x.lv/” /> </html> source It is very hard to filter that out during the upload, so it is just not allowed by default.

Pre populate WordPress wp_media modal with image selection

Here is the script: I’m using the function loadImages in following script to load the existing attached images via AJAX and then just pass the function with the IDs of images and it opens up a pre-populated modal. var frame, selection = loadImages(images); $(‘#stag_images_upload’).on(‘click’, function(e) { e.preventDefault(); var options = { title: ‘<?php _e(“Create Featured … Read more

Add a menu item to WordPress 3.5 Media Manager

OK, I think that I have something that is really close to be an answer: I put my code in a gist Here is the result : I built several Backbone object to respect the MVC pattern : the controller.Custom is in charge of doing all the logic, the view.Toolbar.Custom deals with toolbar buttons, and … Read more

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