getting uploaded SVG dimensions on front-end

I agree with Tom J Nowell on the use of SVG, but if the upload is an actual image, you can tap into the attachment attributes using, as you suggested, wp_get_attachment_image_src. Those dimensions are actually already recorded and stored when using the WP media uploader, it’s likely that the plugin you’re using makes use of … Read more

Resizing only featured images while uploading

You can simply set all unused image size attributes to 0 to stop WordPress generating them. Whilst this only applies for default image sizes, you can use filters to remove them. In general, WP stores all those sizes to generate images for in the global $_wp_additional_image_sizes. The following plugin uses a filter to remove sizes … Read more

Prevent image upload unless exact size

Haven’t tested it, but this should work: // check for file upload size // { if( !current_user_can( ‘administrator’) ) add_filter( ‘wp_handle_upload_prefilter’, ‘mdu_validate_image_size’ ); } add_filter(‘wp_handle_upload_prefilter’,’mdu_validate_image_size’); function mdu_validate_image_size( $file ) { if ( mime_content_type($file) == ‘application/zip’ ) { mdu_validate_zip_image_size($file); return $file; } $image = getimagesize($file[‘tmp_name’]); $minimum = array( ‘width’ => ‘800’, ‘height’ => ‘450’ ); $maximum … Read more

How to crop image from image src in a specific size

WordPress has a function solely designed for this purpose. the attachment_url_to_postid() allows you to retrieve an attachment’s ID from it’s URL, which then you can use to get the post’s ID later. If you want to do it by writing a MySQL query, i would however prefer to suggest searching the file’s name in meta_value … Read more