You have to add the metadata information with the new b&w thumbnail:
$meta['sizes']['thumbnail-bw'] = array(
'width' => $meta['width'],
'height' => $meta['height'],
'file' => $file
);
after generating the new image (after the switch
block).
There ‘s also a plugin, called Grayscale, that does exactly what you need.
Related Posts:
- WordPress set featured image to first image of the post
- add_filter with specific thumb names
- Filter to remove image dimension attributes?
- add_action(), add_filter() before or after function
- Trouble understanding apply_filters()
- What is the very earliest action hook you can call?
- wp_headers vs send_headers. When to use each?
- Removing Image and Caption Dimension Attributes
- How many filter/action hooks are healthy?
- Changing JPEG compression depending on image size
- Earliest hook to reliably get $post/$posts
- Remove Editor From Homepage
- What does (10, 2) mean when used with add_filter
- Valid characters for actions, hooks and filters
- Advanced Custom Fields and Yoast SEO keyword analysis [closed]
- How to check if a hook is hooked or not?
- Is it possible to use object in add_action?
- Change WordPress image URLs via filter
- Remove title attribute from images
- Store source permalink on XMLRPC calls
- Disable resizing of gif when uploaded
- How to make post and comment count unclickable with dashboard_glance_items hook
- Hook into admin post list page
- Anyway to edit the titlebar of WordPress Widgets in the Admin area?
- How do I know if author field was changed on post save?
- Using hooks to place content in theme dynamically
- About Hooks and Filters
- PHP5, Inheritance, Singleton – action & filter hook limitations
- Should I use add_action(‘publish_post or add_filter(‘publish_post?
- Please explain me what the do_action does
- Apply the_title filter to post titles AND backend auto social-sharing plugin, but not nav menu
- add_action uses ‘echo’ add_filter uses ‘return’, why?
- Add ‘if exists’ to filter
- changing variable through filters or action hooks
- Too many actions/filters!
- Apply a filter only once
- How to get list of all hooks of current theme / plugin?
- Making a class available via actions filters
- How does WordPress call functions attached to a certain action hook before calling functions attached to other hooks
- How to get current action?
- Conditionally call add_action depending on post_type?
- how to change appearence of the content of default post list columns?
- Anonymous function is executed twice in wp_head while added from the_posts filter?
- Explanation for remove_filter used in the below code [closed]
- Disable wordpress image sizes generation
- How to change the blog title with add_filter? details below
- How To Get User Data in Callback Function for pre_user_nicename?
- What’s the best way to split admin-only functionality in the theme’s functions.php file?
- Filter list by a unique meta value dilemma
- alternative to the_content filter
- How would I use a filter to remove header banner on certain post types
- Action hook to control access to certain parts of my site
- Finding actual functions added to hooks and filters
- output custom Posts on a Page
- Replace Data In Post & Update Meta Field Post Is Saved
- How to apply filter on get_the_post_thumbnail()
- How to pass a variable between filter/action functions?
- style_loader_tag not changing stylesheet to preload
- How to change Gallery image url in product page ? In function.php?
- Adding link options in insert/edit link dialog window
- How to redirect a unique link based on login status
- Hook to change the site URL
- Hook to add content after date in post?
- Distinguish between page and post in function
- add_action with associative array
- how to use apply filter for Class?
- How can I see exactly what arguments are being passed through a filter so that I may modify them?
- Does anybody know what the $current_screen ->id for customizer.php is?
- adding an action inside if condition not working
- Using add_filters() , apply_filter(), add_action() and do_action() in extending a plugin
- Action for opening attachment or manipulating all attachment links
- Set post featured image to author image
- Print url to default featured image
- How to filter wp_get_recent_posts() to only posts that have thumbnails?
- Put data in my-account/view-order/id/ page
- What action/filter can be used for modifying the page to be rendered?
- Hook inside a hook
- List all image sizes still getting disabled sizes
- What problems could happen if I replaced add_filter and add_action with the function calling
- check, if any “add_action” function contains string XXXXXXXXX
- changing size image within the content
- How to replace all images in all posts and pages with a different size?
- Remove action added from class
- Custom search fields and AJAX support
- Adding to an array & passing it through do_action/apply_filters
- Hook into ‘when user logs in’ [persistent login]
- Custom registration field to SQL database
- Updating User Profile on Registration
- Is this correct usage of filters in WordPress [closed]
- How would I remove an inline googleAPI font script in the the parent theme header.php?
- Wrapping Featured Image on Add/Edit Page in div?
- Is it possible to make get variable out of filter in Class?
- GET form action. Redirect to self
- Can you call a filter hook by “add_action”?
- I tried to move the featured image below the paragraphs but now it is displaying twice
- How to change content hash value, within the_block_template_skip_link action?
- How to use add_filter to add the extra data to existing array?
- How to use render_block filter in Gutenberg when editing a page?
- WP “optimizing” PNGs into thumbnails 5X larger than originals – FIX
- optimized PNGs 5X larger than originals