0

I have to Greyscale a Background image but the image is getting filled by the posts Thumbnail, So I cant add a :After or :Before And Containers make things messy as I have to overlay images and text in different spots

Its Greyscaling the Content which is the problem for me.

The Expected Outcome enter image description here

My Attempt and Issue

enter image description here

<div class="s-brand-header">
    <div class="brand-container" style="background-image: url(<?php echo get_the_post_thumbnail_url( null, 'full' ); ?>)">

        <img class="brand-header-img" src="<?php echo home_url();?>/wp-content/uploads/2020/04/Asset-1.png">
        <div class="brand-h-block">
            <img class="line-img" src="<?php echo home_url();?>/wp-content/uploads/2020/04/Little-Line-Thing.png">
            <h3 class="railway-simple">BRAND STORIES</h3>
            <h1><?php the_title() ?></h1>
            <img class="line-img" src="<?php echo home_url();?>/wp-content/uploads/2020/04/Little-Line-Thing.png">
        </div>
    </div>
</div>
.brand-header-img{
    position: absolute;
    left: 0;
}
.brand-h-block {
    padding-top: 500px;
    display: flex;
    margin-left: auto;
    margin-right: auto;
    height: 800px;
    flex-direction: column;

    color: white;
    text-align: center;
}
.brand-container {
    -moz-filter: url("data:image/svg+xml;utf8,<svg xmlns=\'http://www.w3.org/2000/svg\'><filter id=\'grayscale\'><feColorMatrix type=\'matrix\' values=\'0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0 0 0 1 0\'/></filter></svg>#grayscale");
    -o-filter: url("data:image/svg+xml;utf8,<svg xmlns=\'http://www.w3.org/2000/svg\'><filter id=\'grayscale\'><feColorMatrix type=\'matrix\' values=\'0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0 0 0 1 0\'/></filter></svg>#grayscale");
    -webkit-filter: grayscale(100%);

    filter: url("data:image/svg+xml;utf8,<svg xmlns=\'http://www.w3.org/2000/svg\'><filter id=\'grayscale\'><feColorMatrix type=\'matrix\' values=\'0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0 0 0 1 0\'/></filter></svg>#grayscale");

}

I'll figure out the Positioning and such out but I dont know how id get just the background to be grayd

another thing ive tried is a Div overlay over the image but the Text is still grayd

.overlay{
    background: rgba(0, 0, 0, 0.5);
    background-size: cover;
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    top: 0;
    }
<div class="s-brand-header">
    <div class="brand-container" style="background-size: cover;background-image: url(<?php echo get_the_post_thumbnail_url( null, 'full' ); ?>)">
    <div class="overlay">

    </div>

Resolved using:

.brand-containe{
  background-color: gray;
    background-blend-mode: luminosity;
    filter: grayscale(100%);
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 0;
    background-image: inherit;
    background-size: cover;
    opacity: 1;
}

Azurry
  • 491
  • 3
  • 16
  • Hello, this code can't run anywhere properly because it is a wordpress site and nothing loads out.So I can't help.Can you share your github repo link?Or share me the link of website. – Rishab Tyagi Apr 30 '20 at 10:46
  • *the image is getting filled by the posts Thumbnail, So I cant add a :After or :Before* --> you can do it using inherit, check the duplicate – Temani Afif Apr 30 '20 at 10:48
  • Could u Possibly share a link Temani? Dint know that. And @RishabhdevTyagi You can simply swap my Generated images out with any image youd like Theres no reason youd need a wordpress instilation to test this At least IMO, The idea is for it dynamic so the "Loaded content" Shouldnt matter – Azurry Apr 30 '20 at 10:52
  • Thanks Temani appreciate it – Azurry Apr 30 '20 at 11:03

0 Answers0