When I used your exact code on a local test site I was unable to save the resized image. This is because you’re passing a URL to wp_get_image_editor() instead of a path. You’re also passing a URL to pathinfo()
, which also requires a path.
$pathinfo = pathinfo( $uploaded['url'] );
$image = wp_get_image_editor( $uploaded['url'] );
The above lines need to be:
$pathinfo = pathinfo( $uploaded['file'] );
$image = wp_get_image_editor( $uploaded['file'] );
This is because the file
key of the array returned by wp_handle_upload()
contains the path to the file, which is what each function above requires.
I can’t explain why you’re able to access the 300×300 version in the browser though. That didn’t happen to me when I tested. It could be something specific to the WordPress.com hosting environment.
Related Posts:
- How to force Media manager to overwrite files of same name?
- How to fix the error “file_get_contents was found in the file functions.php”?
- How can I stop WP media uploader from creating duplicates of my uploaded images?
- How wordpress handle upload images and how to use them in the code
- Get attachments by user
- How to regenerate thumbnails when they’re stored on S3
- Convert PHP readfile to WP_Filesystem
- How can one update a theme on a live site without interruption?
- Creating directory and file using native wordpress file system
- Adding wp_enqueue_media(); causes problem
- How to upload images using Settings API
- trying to use wp_handle_upload with ajax
- Media Uploader in custom path
- Customizer: Unique identifier that distinguishes which image upload control is uploading an image
- How can i attach the attachment-ID to the user profile image?
- WordPress Media Uploader in page template (On Front-end)
- Can I get the ID of an inserted / linked image?
- Can I add an icon & function to the “Upload/Insert” toolbar at the top of the content editor?
- wp.media issue with selected image
- WordPress creating images if uploaded image is greater than 960px on one side?
- Callback Function Not Firing On Selection In Media Uploader
- HTTP Error when uploading images over specific dimensions
- WordPress uploads do not show up and I see the white screen of death in some cases
- Can’t upload images on new theme
- Website Developer has gone missing! How to gain full access of your code from a WordPress website?
- Custom Theme functions.php – Using add_settings_field and input type=”file” to set custom logo
- How important is it to enqueue a theme’s stylesheet?
- Can a theme be built in React?
- register_sidebar ignores ‘id’ and ‘class’
- Single Page WordPress Theme – Using page templates
- Confused about image sizing business in WordPress
- Add link option to featured image?
- Creating the modern ‘single page’ html5 css3 layout in wordpress
- esc_url not working within add_settings_field callback
- How to hide and content from auto-generated excerpts?
- How to override BuddyPress 3.0 bp-nouveau theme files?
- Which theme foundry has clean coded themes, where code is poetry [closed]
- Same footer on all multisites blogs
- New template, where to place CSS?
- WordPress not registering Theme Customization Section
- For best DB performance should I serialize all theme options together or by type?
- Find the Children of a Page then Echo it as a Bulleted List of Links (menu)
- Non-Blog Website without Search: are comments.php and search.php in theme still required?
- Custom Widget options in theme
- Include Parent functions.php in Child Theme functions.php
- Redirect to specified page when insufficient permissions?
- Reasons why all thumbnail sizes aren’t working
- Jetpack Comments with fall-back
- Update a custom theme with Subversion?
- wp_script_add_data doesn’t seem to work
- How to override checkbox styles if these inputs have a unique id [closed]
- Theme Development: Starter Content after hook
- Custom page template with custom fields
- How do i place same widgets multiple time by default on theme activation?
- Getting php_network_getaddress error : No such host is known?
- HTML added to editor when deleting shortcodes in Chrome browser
- Combining CSS files into a single cached one
- How to set a page as homepage in stead of the newspages?
- WordPress Theme Validator?
- Get the amount of posts on a given page
- How do I use a color from theme options?
- Second menu has the first menu ID
- How to include a file only on dashboard widgets page?
- WP_Query $gallerypage->the_post() giving Undefined offset: 0
- Change Image Sizes for Mobile Theme
- Dynamically Populating Image/Excerpt/LInks from Pages in WordPress
- Trouble in creating a custom template on twentyeleven theme
- language support in a custom urdu theme
- If I remove Category base from my URLs, how difficult will rollback be?
- Is there a list of default generated Gutenberg block CSS? Unable to align video blocks
- In wordpress customizer div still showing even if I hid it with javascript
- Programatically Created Menu not Editable in Dashboard
- Embedding CodePen Calorie Script – jquery error
- Is it possible to echo a woocommerce prouct attribute discription?
- WordPress Menu item > Sub menu Class update
- Duplicate child theme incl. design changes
- Why .widget-area is outside of .site-content in Underscores starter theme?
- How can I use a different template file for the blog index’s paginated pages?
- How to customize the colors within a stylesheet using a WordPress setting
- On wordpress, how do i require specific dimensions from user uploads only
- how to create export / import theme options in wordpress without plugin
- WordPress Customization API overwrite LESS variable
- Modify comments_popup_link output
- Create image with imagepng() (fails at header)
- Can you create a custom page with content in the center already defined?
- Dynamic meta description
- How to Remove Sidebar when get_sidebar() is not get called in page?
- RSS feed url showing page not found. How to solve it?
- Enable WP to accept standard jQuery code embeding between the tags [duplicate]
- Extending arrays in parent theme without completely overriding the files
- Retina ready for uploaded images which are cropped
- Toolbox theme using printif statement – help needed understanding code block
- Search Results not displaying for multiple word search
- Allow users to edit home page from WordPress (home.php problems)
- WordPress does not know the parametrs i sent to admin post
- Display Page featured Image as well as Posts featured Image
- Custom Single Page Portfolio Theme [closed]
- ways to create customized theme (hard coded – no pagebuilder)
- Can’t select my block by clicking on it on apiVersion – but using blockProps
- Webpack does not create or update index.asset.php file in build folder