You can get the original sizes of the image being uploaded:
list( $uploaded_width, $uploaded_height ) = getimagesize( $_FILES['u_img']['tmp_name'] );
Then you can use those values to size the image as you like:
$height = 300;
$image = wp_get_image_editor( $_FILES['u_img']['tmp_name'] );
$image->resize( $uploaded_width, $height, true );
Related Posts:
- Redirect to another page using contact form 7? [closed]
- How to write “alt” tag in image for wordpress code?
- Is there a way to insert multiple images into a post at the same time without using a gallery?
- How to wrap image tag into div for post only?
- How to show post attachment image
- Between functions.php (theme), widgets, and plugins, which is loaded first?
- How can I make add_image_size() crop from the top?
- Add Plugins to WordPress Theme
- wp_enqueue_scripts not working in custom theme
- What is the correct way for a theme to support plugin UIs?
- Way to force media uploader use custom image size
- How to call “page specific menu items” in template [closed]
- Create WooCommerce Product Category Programmatically
- How do I make my wordpress page more friendly for mobile viewers?
- WordPress Enqueue Script Chaos (jQuery & Foundation.js)
- login to wordpress with Get variables instead of Post
- Check javascript file Proper way in functions.php
- Should I use RIPS tool to test my themes and plugins?
- Upload images from custom plugin using the media modal
- Layout shop page: resize images and columns
- How to crop image from center using wp_image_editor
- How to show category images (from plugin) on a regular page (page-example.php)?
- Saving/Writing/Adding file to upload folder
- How can I get full attachment url from wp_get_attachment_metadata?
- Translating plugin inside the theme [closed]
- unzip a folder on specific location and delete the zip file
- Editing Theme to apply Co-Authors Plus
- Converting Attachment to Images?
- How to limit WordPress pages during updates?
- Why is the Settings API is not saving my array of options
- Bulk Image Uploader to create new post from each image [closed]
- How to integrate plugin in WordPress theme
- How do you remove plugin edit option?
- How to add a random image to a post from gallery and only show one?
- Override the filter from plugin in child theme
- how to load the language file in plugin?
- Different UI in WordPress
- Set featured image randomly from WordPress Database on post submission
- wp_get_post_terms is difference obj model than the one in rest api response
- How generate 200% image size and save with suffix @2x
- Best place for short bio,image and button [closed]
- How to upload WordPress Images to remote web server and display those images in WordPress gallery [closed]
- WordPress shows error related to allow_url_fopen
- How to show only next post pagination link using wp_link_pages()
- wp_footer hook only working on homepage not in other pages
- Retrieving Meta from Image Attachment
- Plugin can not display in my custom theme
- How to apply lazy loading in background images [closed]
- How do I combine a theme with a plugin
- how to force tag page layout to use same as search layout?
- Woocommerce showing images blurry in description page
- Getting taxonomy images to display on single-post with their terms
- How to multiply a post to test internal search results?
- Use different single.php file based on condition
- Image crop, resize and compression plugin?
- How to Resize the Custom Post Images?
- Images under 1MB are not being compressed
- Widget for specific category
- How to customize this theme? [closed]
- Overwrite add_image_size defined by theme
- Don’t load the theme for a page FROM a plugin EDITED
- Extending a theme: build new features as plugin or core modules?
- Remember the Meta Value With Radio Buttons
- WordPress plugin with its own “site”/theme
- Theme Functions run a function upon activation or preview
- Is there a Image Gallery which will load all my posted Images like twitter’s image grid?
- Offer Download Links for Product Images
- Elementor Sidebar not loading when PRO elements plugin is active
- How would I get the new plugin version on this function?
- Optimal image size for wordpress?
- Copy/paste local images not working in WordPress
- How to add height and width to images on a page(using WP Bakery) to improve Google’s CLS score?
- Is there a way to auto generate poster image for videos
- I need to register and resize images, safe to delete plugin afterwards?
- How to get checkbox by default true in metabox?
- How much PHP and MySQL or MariaDB knowledge should I know to start writing WordPress themes and plug-ins and whatever else a beginner can edit?
- Is it possible to customize a wordpress post from outside dashboard(Something like site.com/post-type/post/?e=post_id)?
- Looking for Image Slider that is based on default WP Media Library
- When the user entered an unauthorized url redirect to login page
- Show content from plugin on index
- How to Display image from Menu Image in Walker Dropdown Select Menu
- Get plugin to background of page
- Is there any hook to change media html in post? [duplicate]
- export high ress images to pdf
- adding image in the header of my dev widget
- Directory structure for plugin changes
- Advanced Custom Fields (ACF) Plugin – Random Image in Sidebar
- Images not showing and plugins not installing on wordpress server move
- Adding hero images to blog posts
- How to generate a responsive output from plugin?
- How to work email subscribe in WordPress?
- Is there a WordPress Plugin like Imsanity that keeps high resolution originals? [closed]
- Open graph issue on my theme
- Images get uploaded itself from the computer
- Editing a theme
- Ajax button “Load more” is not loading correct language version posts for logged out users
- How to code a wordpress page properly? Dashboard or unique Theme files or alternative?
- how to make wordpress remember my choice
- Meta box not displaying on the plugin page
- Getting error when accessing Customizer Page