Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Shells Virtual Desktop
BMail.ag - Secure Email Service
Server.net
CPLicense.net
VPS Server
Buy VPN
Vultr
VMs for AI
HostDare
HostDare
ReliableSite White-Label Dedicated Hosting for Resellers
InterServer VPS
BMail.ag - Secure Email Service
Best VPN
High-Performance Bare Metal Server Solutions
Karvl.com
Server Mania Cloud Hosting
DataWagon Hosting
AlphaVPS Hosting
Evoxt.com
Clouvider
VPS Hosting with NVMe
Residential IPs in the US & 4G Mobile Proxies in EU & US with Unlimited Bandwidth
ReliableSite White-Label Dedicated Hosting for Resellers
Rabisu - Hosting Solutions
Shells Virtual Desktop
New on LowEndTalk? Please Register and read our Community Rules.

All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.

Wordpress Help

agoldenbergagoldenberg Member, Host Rep

I'm looking to have wordpress strip out the following class that seems to be on every image but is not used anywhere.

wp-image-nnnn where nnnn is a number reference to what I believe to be the media ID.

Can anyone lend a hand?

Comments

  • I think you can filter this with the get_image_tag_class filter. I'm basing this off a quick search of the WordPress code.

    Thanked by 1Falzo
  • FalzoFalzo Member
    edited April 2016

    as far as I can see, this is referenced in

     wp-includes/media.php
     wp-includes/js/tinymce/plugins/wpeditimage/plugin.js
     wp-includes/js/media-editor.js
    

    especially the javascripts use functions like

     classes.push( 'wp-image-' + imageData.attachment_id );
     props.classes.push( 'wp-image-' + attachment.id);
    

    so maybe it is not the best idea to try and get rid of it, because it may break things...

    and as those files are core-files of WP and it looks like those classes are attached via js anyway, I'd definitely recommend to go and try to remove it with javascript also.
    that you can easily put as a custom function into the footer of your theme or something alike. otherwise changes to the core-files will probably be overridden on the next update.

  • FalzoFalzo Member

    @JustAMacUser said:
    I think you can filter this with the get_image_tag_class filter. I'm basing this off a quick search of the WordPress code.

    +1 for this, good hint!

    just read across and it seems that only the tinymce and media editor are adding those classes via js. so maybe the risk of breaking something by removing it for the visitor changes to very low ;-)

    that way one may be able to filter it before the html output is generated, as suggested over there http://wordpress.stackexchange.com/questions/120133/strip-image-classes-from-html-output

Sign In or Register to comment.