to test the post type where the image is included, try that :
add_filter("media_send_to_editor", function ($html, $attachment_id, $attachment) {
$image = get_post($attachment_id);
$post = get_post($image->post_parent);
if ("CUSTOM_POST_TYPE_CODE" === $post->post_type) {
}
return $html;
}, 10, 3);
Related Posts:
- Filter by custom field in custom post type on admin page
- How can I filter posts by post_parent in the admin?
- How to Make an admin_notices Message That Disappears Once the User Leaves That Particular Page?
- Filter by custom Field for Custom post type Admin Listing
- Image size filtering in Media uploader according to custom post type
- Unable to filter on field on edit.php page
- How to Change the Title of a Meta Box on a Specified Custom Post Type? [duplicate]
- Adding help information to custom post edit page
- Filters post in admin with dropdown select, custom post type
- Admin List Dynamic Heading
- How can I add a column in the wp_list_table of the admin area?
- Add html to cpt main page / admin edit.php
- filter custom post type by meta key in dashboard
- Filtering posts list table
- sortable columns for multiple custom post types not working
- Is there any filter to add a custom attribute to the tag in admin panel?
- Change column of row action (Quick Edit) links in WP_List_Table
- Adding HTML tags or css classes to admin columns
- How can I see a list of my Custom Post Types of the last term I was in?
- uploading images to specified directories
- Customize the Dashboard Menu Editor
- Filtering WP_Query
- Create a page that will be used to create a custom post type
- WordPress 3.5 Media Uploader – Only allow 1 upload and certain file types
- Customize my custom taxonomy table in Admin panel
- Displaying custom taxonomy in the admin list of a custom post type
- Get parse_query filter to return slug instead of id
- Custom Post Type Nav to Subpage
- How can I run this code once so that my generated post title doesn’t keep changing on publish/update?
- Selecting a post in Dashboard
- Custom admin post.php page
- Categories of custom taxonomy don’t show any posts
- A simple script to allow sorting of custom posts in admin?
- How to add a custom-post-type post within another custom-post-type post edit screen using AJAX?
- Notify admin on new submit
- How to add a post slug to a url?
- Team club with CPTs and user registration + user dashboard
- On update or create post redirect to current post position in list
- WordPress sort search results by custom order
- How to filter wp_list_categories output with some custom post type meta query?
- How to Filter custom post type by taxonomy?
- Cluster CPT posts to users based on ACF value from their profile on dashboard
- Filter term taxonomy metabox in custom post type
- creat filter with wp_query
- A method for ordering mixed dates in search result loop (theory only, no actual code)
- Options page – dropdown of users
- How can I made custom taxonomies relationship?
- WooCommerce sort products by the actual product width(not the shipping width)
- How to change the post type a theme shows by default?
- filter custom post in rest api with custom function
- No Permission to add new Page, Post or CPT with Admin role
- Filter hierarchical custom post type admin page by parent, and include children & grandchildren
- Sort and filter custom post type posts by custom taxonomy
- Versioned Custom Post Type (Not the same as revisions)
- Admin Column does not populate with data
- Loop filtering Custom Post Types and/or Categories
- search suggest – filter post type
- the_content filter on some post types only not working
- CPT Validation to not show “Post updated.”
- Custom filter function not working with Custom post type
- Edit Custom Post Type on Custom Admin Page instead Post Admin
- Filter Posts from the Main Query
- Categories filtering in new post
- How to use manage_$post_type_posts_columns with underscore in post type?
- How does the filter post_updated_messages work?
- Search filter triggered & sort by custom post type
- How to order posts of a custom post type by date DESC in dashboard Admin?
- Custom post type isn’t working
- How can I add a filter to a particular post format?
- Is there any way to get list of all possible filter hooks for all post types?
- Can I display custom post types in home.php or need page template?
- Create new custom post and post category of same name
- Add a ‘guide’ image to custom post type admin page
- wordpress remove views from action links in a custom post
- wp_insert_post wrong post type [closed]
- Use remove_meta_box conditionally on custom post type
- New “Custom Types” item in admin menu. Is this a plugin or a new wordpress feature?
- How to group navigation items in the admin panel
- Filter posts by tax (dropdown) and meta value
- Sortable column containing numeric values for Custom Post Type at WordPress Backend
- How to check if post/page or taxonomy post is published by admin
- Linking to Post Types from wp-admin
- Plugin or method of allowing user to rearrange custom post types with drag and drop?
- How can I remove filters from custom post types?
- CPT Columns doesn’t show categories
- Insert Custom Post Types
- I need to add a filter to prepend the term ‘National – ‘ to the post title if the post is tagged to multiple states
- Custom Post Type – Support “author” only for admins
- How do I add custom HTML to the content of an archive page’s posts?
- Only show posts with a specific term of an associated taxonomy in a custom post type archive
- REST filters only firing when I have a param set
- Showing User’s Post Counts by Custom Post Type in the Author.php?
- List Custom Post Types in Admin Dashboard
- Problem with Apply Filters on URL in meta box filed of custom port type
- how to retain the ability to modify the post slug after applying a post_type_link filter?
- Add ‘page template’ column to dashboard for CPTs
- How do I show a link or ‘Read More’ button on a custom field excerpt when it is less than the word limit
- How to filter url on post submission?
- Filter posts of custom post type by meta key in (List All Section)
- Add data to post edit page, when post is published