Wordpress Help

Wordpress Help

agoldenbergagoldenberg Member, Provider

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?

Tagged:

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.

    Netcup DE KVM: 1vC 1GB - 18,88€ or 2 Core 3GB 240GB - 49,88€ yearly /w 5€ off: 36nc15113816461 - 36nc15113816469
    UltraVPS.eu KVM in US/NL/DE, BLACK FRIDAY: 1GB 20€ or 2GB 40€ yearly or cheap 750G / 2TB storage offers

  • 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

    Netcup DE KVM: 1vC 1GB - 18,88€ or 2 Core 3GB 240GB - 49,88€ yearly /w 5€ off: 36nc15113816461 - 36nc15113816469
    UltraVPS.eu KVM in US/NL/DE, BLACK FRIDAY: 1GB 20€ or 2GB 40€ yearly or cheap 750G / 2TB storage offers

Sign In or Register to comment.