I managed to figure it out myself (numbers of hours spent: way too high).
Initially I thought using the unfiltered_html
capability for administrators would solve the issue. Even if it would (which it didn’t), it would be somewhat of a shotgun approach to a revolver issue.
Upon further searching, I learned that wordpress has a global list of allowed tags/attributes. Adding my attribute to the image tag solved it:
add_action( 'init', 'add_data_orientation_to_posttags' );
function add_data_orientation_to_posttags() {
global $allowedposttags;
$tags = array( 'img' );
$new_attributes = array( 'data-orientation' => array() );
foreach ( $tags as $tag ) {
if ( isset( $allowedposttags[ $tag ] ) && is_array( $allowedposttags[ $tag ] ) )
$allowedposttags[ $tag ] = array_merge( $allowedposttags[ $tag ], $new_attributes );
}
}
Related Posts:
- WP 4.4. responsive images browser choosing the “wrong” one
- Allow contributor role to upload images and not edit already published articles
- Remove images (files) that were generated when using add_image_size()
- Using Images in WordPress – Best Practices
- Change html structure of all img tags in WordPress
- How to create thumbnails with a fixed width, so all of them will have the same width?
- Creating a rotating header /image slider using theme customization
- Adding HTML within an image title attribute
- How do I delete thousands of unattached images?
- How to remove link from an image in a post?
- Change html structure of all img tags in WordPress
- Limit author image size
- Setup A Default Featured Image
- What’s the best “insert all images” plugin?
- Any way to “combine” galleries or show multiple galleries as one?
- Can I the caption shortcode to set caption to a data attribute, and with the image’s alignment intact?
- Remove image classes from post thumbnail output
- How can I make all post image uploads have data-width and data-height attributes automatically by default?
- Photography Based Design – Multiple Images Per Post
- wp_upload_bits does not retrieve images that do not have an extension
- Get ALT attribute from title post (code not work)
- Image LazyLoad plugin not loading jQuery dependancies with wp_enqueue_script in WP 3.3.1
- How to check for images before echo
- Remove height attribute from wp_get_attachment
- Images give 404 after changing default domain
- Need custom picture field for pages
- Disable save as image on smartphones using all browsers ( chrome, firefox, ie, cm, opera )
- Apply nextgen-gallery lightbox effect [closed]
- How to pass on a value as parameter via url to another page
- Allow admin roles to add images to comment replies
- How to make image uploads default to full size?
- WordPress 404 Images – Images not found after deleted from media
- Alt attribute is not showing while the value is given in Media
- WooCommerce Variation Swatches and Photos – get attribute thumbnail
- Get “Image CSS Class” value from the Advanced Options section
- Unable to delete images in Media Library
- Dinamically modifying attributes of images on posts
- How to add multiple images in a page
- Only User Upload image Http Error
- Remove “align” attribute on images
- Upload button in metabox not working
- Slider do not add alt attribute. Cant get alt attribute from a media library!
- How do I add a nested conditional within an echo – to use a default image if there isn’t one in the post?
- Why images are disappearing on WordPress web site?
- Img alt tag showing different value then entered
- Featured Image not changing
- Uploaded Media Images on Site
- if user role is x – show image – wordpress
- Separate Media Library for each user
- Maintaining image color and quality when uploading using custom sizes
- Bulk edit wordpress images alt and title attributes
- Upload Image Not accessible
- Caption in Page adding unwanted 10px to width
- Why can’t I edit certain images from the WordPress Media library?
- How to add a media with PHP
- Get original image from thumbnail URL
- Bulk image rotation
- Is there a way to delete images from WordPress media library programmatically?
- Update image links in database
- Pull Random Attachments With Pagination
- Upload media files to Amazon S3
- Create custom fields as image uploads [duplicate]
- How to get default image sizes attribute
- Image not shown in the theme as it’s showing in HTML template [closed]
- Broken Images until Page Refresh
- Get image from parent category
- Images attached to posts from library link to 404 error page
- Specific image size is being generated without being registered
- Should I not compress my jpeg files before uploading to avoid double compression?
- Generating a certain sized thumbnail on the fly?
- How to display title of attached image in post?
- Link listings with image
- Allow users to contribute images to a post
- After Migration, images show up on a preview of the page but not the actual page [closed]
- Save Image in wp_options-Table
- Image upload error?
- Image not showing using a custom function and get_post_meta
- Random home page background images with caption text
- How to add “alt” attribute for image during upload at WP front-end?
- Excluding post thumbnail from the attachment.php when using wordpress gallery
- Pictures randomly replaced by blue question mark
- WordPress PHP custom function is causing 500 Internal Server Error Connection Timeout
- Post-processing of the image failed
- Get post thumbnail in specific size
- Text not wrapping properly around image in WordPress Visual Editor [closed]
- How to regularly backup and update WordPress website with lot of images?
- Resize images to match CSS
- Featured image appears in header
- Preventing the image-post problem from ahead (edit: without redirects)
- How to put images into theme from server folder (not from media library)
- How can I stop WP Image Editor upscaling from looking so pixellated?
- Declare global variable that can be used on other function
- How to show images uncropped after uploading?
- add_image_size() width not actually working
- WP_Customize_Image_Control and selecting from library?
- Black and White Thumbnail in WordPress Gallery
- Get a different size of Image thumbnail while working with custom metabox
- WordPress update leads to 404 error on admin page and signup. CSS mishap with all plugin related functions
- How to get dimension of Logo and Crest
- WordPress Missing Images