Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Blank colour svg injected as bg image #410

Closed
Cstrachan4 opened this issue Sep 26, 2024 · 4 comments
Closed

Blank colour svg injected as bg image #410

Cstrachan4 opened this issue Sep 26, 2024 · 4 comments
Labels

Comments

@Cstrachan4
Copy link

Cstrachan4 commented Sep 26, 2024

Describe the bug

After updating to version 5.0.2 images are getting a grey svg injected as a css background via the style attribute meaning images with a transparency show a grey background instead. (downgrading to 5.0.1 fixes the issue)

To reproduce

Steps to reproduce the behaviour:

  1. Have image with transparency
  2. View on front end

Expected behaviour

This style attribute shouldn't get injected ('generatePlaceholders' setting is set to false)

Screenshots

Screenshot 2024-09-26 at 11 29 56

resulting in

Screenshot 2024-09-26 at 11 29 37

Versions

  • Plugin version: 5.0.2
  • Craft version: 5.4.5.1
@Cstrachan4 Cstrachan4 added the bug label Sep 26, 2024
@khalwat
Copy link
Contributor

khalwat commented Sep 27, 2024

Can you show me the code you're using to output said image?

@Cstrachan4
Copy link
Author

Sure, here you go:

In template

{% block bWhoBlockImage %}
      {% if whoBlockImage %}
            {# Output optimized image #}
            {{ whoBlockImage.imageTransformMax.pictureTag()
              .pictureAttrs({
                  'class': 'who-section-block__image',
              })
              .imgAttrs({
                  'alt': whoBlockImage.alt ??? ' ',
              })
              .loadingStrategy('lazy')
              .render() }}
      {% endif %}
{% endblock %}

Component

{% if whoBlockImage or _whoBlockImage is defined %}
      <div class="who-section-block__image-wrap">

        {% block bWhoBlockImage %}

          {% if _whoBlockImage %}
            <img class="who-section-block__image" src="{{ _whoBlockImage }}" alt="" />
          {% endif %}

        {% endblock %}

      </div>
{% endif %}

@khalwat
Copy link
Contributor

khalwat commented Oct 9, 2024

This is a result of the lazy loading strategy that is being used which works fine for normal images, but not for images like SVGs that can be transparent in places.

I'm looking into a solution that makes sense here.

@khalwat
Copy link
Contributor

khalwat commented Oct 9, 2024

Addressed in the above commits.

Craft CMS 3:

You can try it now by setting your semver in your composer.json to look like this:

    "nystudio107/craft-imageoptimize": "dev-develop as 1.6.56”,

Then do a composer clear-cache && composer update

…..

Craft CMS 4:

You can try it now by setting your semver in your composer.json to look like this:

    "nystudio107/craft-imageoptimize": "dev-develop-v4 as 4.0.10”,

Then do a composer clear-cache && composer update

…..

Craft CMS 5:

You can try it now by setting your semver in your composer.json to look like this:

    "nystudio107/craft-imageoptimize": "dev-develop-v5 as 5.0.3”,

Then do a composer clear-cache && composer update

@khalwat khalwat closed this as completed Oct 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants