Notice: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the wp-ulike domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /home/illphate/public_html/wp-includes/functions.php on line 6131

Notice: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the astra domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /home/illphate/public_html/wp-includes/functions.php on line 6131

Deprecated: Function WP_Dependencies->add_data() was called with an argument that is deprecated since version 6.9.0! IE conditional comments are ignored by all supported browsers. in /home/illphate/public_html/wp-includes/functions.php on line 6131
How To Hide A Specific Image Using CSS Code | Illphated Dot COM

ILLPHATED dot COM

 
 

How to hide a specific image using CSS code

NORDVPN_ILLPHATED
SHARE THIS NOW!

illphated

hide this image

✅ Option 1: Hide by src (recommended if it’s unique)
css
Copy
Edit
img[src*=”cropped-illphated_logo-1.png”] {
display: none;
}
✅ Option 2: Hide by class
If that image is the only one with this exact combination of classes:

NORDVPN_ILLPHATED

css
Copy
Edit
img.wp-post-image.lazy-loaded {
display: none;
}
✅ Option 3: Hide by specific size
css
Copy
Edit
img[width=”512″][height=”512″] {
display: none;
}
✅ Option 4: Hide by alt (if you set one)
css
Copy
Edit
img[alt=”Your Alt Text Here”] {
display: none;
}
Where to put this?
Inside your theme’s style.css

Or in WordPress Admin → Appearance → Customize → Additional CSS

EmailURL

3 thoughts on “How to hide a specific image using CSS code”

  1. no by attachement ID

    ChatGPT said:
    Ahh got it — if you want to hide the image by attachment ID, you’ll need to check how it’s rendered in the HTML or how WordPress outputs it, because standard tags don’t include the attachment ID directly in the HTML.

    However, here are your best options:

    ✅ Option 1: Add a custom class using the attachment ID via WordPress PHP
    If you’re editing a theme or plugin template, you can output a custom class like this:

    php
    Copy
    Edit
    echo wp_get_attachment_image(123, ‘large’, false, array(‘class’ => ‘hide-this-image attachment-id-123’));
    Then in your CSS:

    css
    Copy
    Edit
    img.attachment-id-123 {
    display: none;
    }
    ✅ Option 2: Use CSS to target based on src if ID is not in HTML
    If the image tag looks like this and has no ID:

    html
    Copy
    Edit

    You can still hide it like before:

    css
    Copy
    Edit
    img[src*=”cropped-illphated_logo-1.png”] {
    display: none;
    }
    🛠️ Want it dynamic? Here’s how to add the ID to the class (via WordPress filter):
    Add this to your theme’s functions.php:

    php
    Copy
    Edit
    function add_attachment_id_to_image_class($attr, $attachment, $size) {
    $attr[‘class’] .= ‘ attachment-id-‘ . $attachment->ID;
    return $attr;
    }
    add_filter(‘wp_get_attachment_image_attributes’, ‘add_attachment_id_to_image_class’, 10, 3);
    Then in your CSS:

    css
    Copy
    Edit
    img.attachment-id-123 {
    display: none;
    }

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top

Notice: ob_end_flush(): failed to send buffer of zlib output compression (0) in /home/illphate/public_html/wp-includes/functions.php on line 5481