Replies: 2 comments 3 replies
-
Firstly, let me say that I greatly appreciate the suggestions and discussion, as always!
Using
Many of these issues could be mitigated with some additional input validation and setting some kind of timeout (is that possible with this function?), but even then it would be very difficult to properly and securely do all of that. So for those reasons, I'm inclined to decline that, but third-party libraries are certainly welcome to implement that at their own risk ☠️
If you wanted to set those for all images via config, the Default Attributes extension is designed for exactly that purpose. Would that satisfy your needs? We could even include specific examples of those attributes in the docs to help others find that solution. WDYT? |
Beta Was this translation helpful? Give feedback.
-
All right, now I feel like a tool because I didn't differentiate between the Attributes extension and the Default Attributes extension (despite the link)...here we are. Happens and apologies again. Yes, for the loading and encoding Default Attributes works; browser tested. use League\CommonMark\Extension\CommonMark\Node\Inline\Image;
'default_attributes' => [
Image::class => [
'loading' => 'lazy',
'decoding' => 'async'
]
] Re:
I think that would work. I'm also thinking it might be helpful to describe a bit more about how Default Attributes works from a specifying it perspective; honestly, it kinda frightened me a bit and I didn't fully understand it when I added it to the fluent markdown library. (I can see what I can do to help there, if you like.) I'm presuming this would possibly apply to custom extension nodes as well - like the abbreviations one?? Definitely makes implementing the extension easier, I think. Now it's just the height and width piece. Thanks again, as always! |
Beta Was this translation helpful? Give feedback.
-
Been thinking about 3 areas related to images and the optimization project I'm doing...none of which are part of a Markdown spec; I don't think.
All three (four) are already possible using the attributes extension. With that said I think the last two could be easily achieved through the config -
false
means don't bother, with either two or three possible strings. So, doesn't collide with or break spec compliance and no added syntax from the other, which would be required using the attribute extension. With that said, setting width and height is recommended if doing 2, 3, or both.Image height and width could be derived using getimagesize and maybe adding a setting to the config to say whether you want this as part of the output - false by default; again, no deviation from spec and lets Markdown remain more for authors and light on syntax. (Could be a performance hit though.)
With that said, maybe I want to specify a different height and width in the rendered markup. I've seen a couple that can integrate seamlessly into the Markdown by appending it to the URL. One using a fragment and could be modified to seamlessly integrate, it's the {space}=WxH syntax. Though this would break with the specs, which don't support image width and height natively as part of the syntax.
Thoughts on any or all of these ideas??
I've been considering creating an extension and wondering what might be able to go directly into core.
Beta Was this translation helpful? Give feedback.
All reactions