I'm using Blazy and custom layout builder blocks and want to display inline images embedded by embed media. Blazy reserves space for the image but doesn't load it. The loading icon is visible. Inspecting shows:
<img alt="test" title="test" class="media__image media__element b-lazy" loading="lazy" data-src="/sites/default/files/styles/media_standard/public/2021-04/Bildschirmfoto%202021-04-08%20um%2015.06.01.png?itok=klnJ5Y8j" src="data:image/svg+xml;charset=utf-8,%3Csvg xmlns%3D'http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg' viewBox%3D'0 0 1500 719'%2F%3E" width="1500" height="719">
Now, replacing the src with the content in data-src correctly displays the image without removing the loading icon of course. I am unsure what causes this problem and have meddled with different settings in blazy UI, slick UI, text format, etc.
Any ideas?
| Comment | File | Size | Author |
|---|---|---|---|
| #11 | inspect.txt | 7.99 KB | bbombachini |
| #9 | Screen Shot 2021-12-17 at 11.50.28 AM.png | 273.83 KB | bbombachini |
| #9 | Screen Shot 2021-12-17 at 11.48.49 AM.png | 733.34 KB | bbombachini |
| #6 | Screen Shot 2021-12-16 at 6.59.40 PM.png | 362.47 KB | bbombachini |
Comments
Comment #2
gausarts commentedThank you.
It is the latest DEV, or Blazy 2.1, too? I know you marked it DEV, just in case some regressions :)
> display inline images embedded by embed media
Please clarify few terms:
If yes, to both, it was warned at Blazy Filter:
https://git.drupalcode.org/project/blazy/-/blob/8.x-2.1/src/Plugin/Filte...
<b>Warning!</b> Blazy Filter is useless and broken when you enable <b>Media embed</b> or <b>Display embedded entities</b>. You can disable Blazy Filter in favor of Blazy formatter embedded inside <b>Media embed</b> or <b>Display embedded entities</b> instead. However it might be useful for User Generated Contents (UGC) where Entity/Media Embed are likely more for privileged users, authors, editors, admins, alike. Or when Entity/Media Embed is disabled. Or when editors prefer pasting embed codes from video providers rather than creating media entities.If not, please provide detailed steps for reproductions so that we are on the same page.
Comment #3
gausarts commentedAssumed #2 was right. It was a known limitation more than a bug. The solution was also provided early on.
Feel free to re-open if it is not the case. Thanks.
Comment #4
bbombachiniHi @gausarts, I'm reopening this because I have the same problem described here (src doesn't get "translated" to a valid path and starts with
data:image/svg+xml;charset=utf-8The difference is that I'm using to embed the images on ckeditor, they are using a inline view mode that is set to display using Blazy field formatter. I'm on version 8.x-2.5 of the module and I'm not using the Blazy filter on the wysiwyg. By now I can see the images on the backend, but on the front end they just don't display. The embedded images are being migrated, but even adding the exact same markup as one added through the wysiwyg, they don't render when migrated.
I have updated to the latest dev to check if this could have been fixed, but it's not the case. I wonder what could be going wrong with the path/url parsing?
If it helps with anything, I just noticed that it works on a body wysiwyg, but not on a wysiwyg field on a paragraph.
Comment #5
gausarts commentedPlease capture after pressing F12, be sure inspect and expand the failing section.
Not so clear what's going on there :)
Comment #6
bbombachiniNot sure if I took a screenshot of what you expected, sorry. This is what I see in the front end:
And this is what's on the backend:
<drupal-entity alt="" data-embed-button="media" data-entity-embed-display="view_mode:media.inline" data-entity-embed-display-settings="{"link_url":"","link_url_target":0}" data-entity-type="media" data-entity-uuid="a3b496eb-c12a-4077-a9b7-b45fed0efa6b" height="367" width="551" />I also realized that if I go edit the paragraph and I re-save the node, it starts working although nothing changes on the markup. I think this is somehow related to Blazy because this doesn't happen if I display inline images as other display modes like image, responsive image, etc.
Comment #7
gausarts commentedThank you. Almost clear:)
Basically Blazy stops working in there.
Please try 4 below:
Comment #8
gausarts commentedAlso please capture the .field element, normally has blazy blazy--field blazy--on class along with data-blazy when it kicks in.
If some of them are gone, likely overriden by certain field template.
Comment #9
bbombachiniThank you for replying so fast and looking into this!
1. Here's the screenshot of the whole element:

2. The only messages on console were regarding css and some cookie settings:

3. Switching to Bartik made no difference.
4. Confirmed that blazy.load.js is indeed there.
Comment #10
gausarts commentedWeird, all is in place, but no go :)
Last try:
Any Aspect ratio makes any difference?
If still no go, PM me your link, ah but no prod as it seems?
Comment #11
bbombachiniI've enabled twig debug, I went as high as the paragraph itself and I've copied the inspect in this txt file so it's easier to lookup for templates/classes/etc.
https://www.drupal.org/files/issues/2021-12-17/inspect.txt
Comment #12
bbombachiniAspect ratio makes no difference :(
Correct, no production website.
Comment #13
gausarts commented> If it helps with anything, I just noticed that it works on a body wysiwyg, but not on a wysiwyg field on a paragraph.
So at Body text works, but Paragraphs failed?
So I can narrow down.
Comment #14
bbombachiniYes, that's correct, seems that it won't work on a paragraph but same code works when embedding to body. What's also weird to me is that if I edit the paragraph and re-save the node it usually works too.
Comment #15
gausarts commented> re-save the node it usually works too.
Hm, weird indeed.
I need to get some time for this. At least you have been very detailed so I can focus on the problem better.
Frankly, no idea with such conditions by now.
I'll see if I can manage it this week or sooner :)
Comment #16
bbombachiniOk, so I just realized that's when it's inside an accordion that it won't work (I have lots of accordions) and if I set them to be opened by default they do work.
So I'll leave this up to you if you want to investigate further, but I recognize this is a super specific bug. I'll just make the accordion to be opened by default if there's an img embed inside an accordion and problem solved for me, so feel free to close this issue if you think this is pointless.
I'd like to appreciate again all your availability in investigating this and for replying so fast :)
Comment #17
gausarts commented> when it's inside an accordion that it won't work
Yes. We got the known culprit.
Blazy, and any lazy script, script in general which relies on DOM layout lookups, will fail on hidden element.
That is why Drupal has
visually-hiddenclass.Your solution is one way. Normally I used CSS to force display block, and minor JS to toggle visibility with
visually-hiddenclass. This way Blazy isn't screwed up.Also worth trying, one at time clear cache just in case:
Comment #18
bbombachiniYou replied faster than I could write again!
You're absolutely right, I could narrow down the issue and realized the accordions were the real problem here.
Comment #19
bbombachiniSeems that the Load Invisible worked for me, thank you very much!
I'm closing the issue now.
Comment #20
gausarts commentedOk. Glad that it works :)
In case matching design, I normally use Slick navigations to act like tabs, and disable Draggable.
Comment #22
lance lancelot commentedProblem already solved. Template problem. Please close again.