Support » Plugins » Hacks » How to disable images? (0.domain.com)

  • Resolved Isidoros Rigas

    (@isidorosr20595)


    Hello world,

    I have a techblog and I want to create an image-free version, something like 0.domain.com like 0.facebook.com, because I usually use large images. My friend complained that his data (30MB) “dried up” quickly while he browsed Fb and my blog. So, how can I do it if I keep the same theme? Do you think it worths trying?

    Thanks in advance.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Moderator bcworkz

    (@bcworkz)

    You could suppress the bulk of images by filtering ‘the_content’ and stripping out all <img> tags if `$_SERVER[‘HTTP_HOST’] contains the 0 sub-domain. You can suppress others on a case by case basis. For instance, adding a conditional to headers.php could suppress the header image. Some images, such as navigation and icons, might be useful and small enough to not be worth suppressing.

    Thread Starter Isidoros Rigas

    (@isidorosr20595)

    Hi bcworkz and thanks for your answer!

    How to filter ‘the_content’ and strip out all <img> tags if `$_SERVER[‘HTTP_HOST’] contains the 0 sub-domain?

    Moderator bcworkz

    (@bcworkz)

    The code would be something like this (untested):

    add_filter('the_content', 'ir_remove_img_tags');
    function ir_remove_img_tags( $content ) {
       if ( strpos('0.', $_SERVER['HTTP_HOST'])!== false ) $content = preg_replace('/<img.*>/i', '', $content);
       return $content;
    }

    The code can go in your theme’s (preferably child theme’s) functions.php file, or it can be made into a basic plugin. This only removes img tags from post content, other images, such as the header image, need additional code to suppress.

    Note that besides matching a 0 subdomain, this will match a 0 at the end of a domain name, such as www.justinbieberisa0.com.

    Thread Starter Isidoros Rigas

    (@isidorosr20595)

    A bit late, but thank you!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘How to disable images? (0.domain.com)’ is closed to new replies.