Replies: 5 comments
-
Is this when selecting a Craft asset? For regular images, this could be pulled off, but if the user selects a transform, the width and height are unknown until the transform is actually created. |
Beta Was this translation helpful? Give feedback.
-
I usually insert images as transforms, using the rich text editor's interface. |
Beta Was this translation helpful? Give feedback.
-
@nicbou yeah, that'll be a bit problematic, because the final image size will only be known only when the transform is generated, which most of the time won't be when you are selecting that image from the modal. I get the niceties this would offer, but I can't see how it can be pulled off with a reasonable effort. |
Beta Was this translation helpful? Give feedback.
-
As a workaround, I created an "Image" block in my matrix field. This allows me to display image assets however I want:
In hindsight, setting image dimensions would be very helpful, but would still load big images on small screens, and have other limitations. |
Beta Was this translation helpful? Give feedback.
-
I disagree that we should just accept that we cant set the height and width attributes just because a transform might be set and that transform might not be created. Why cant the redactor plugin be updated to account for this shortcoming? Transform can be created at the time the post is saved so that the dimensions can be determined. However, I do think that a better approach would be to change the function of the plugin so that instead of the image tags "rendered" into the field content when the entry is saved, a "placeholder" string would be instead be inserted for each asset inserted into the post. This would require that a map of assets to placeholders be stored with the content (could be as part of a JSON object that contains the map and post data as properties). Upon rendering the field, the placeholders would be replaced in real time with the HTML code that could generate the transform if needed at runtime to properly create the Not be a "stickler" but the |
Beta Was this translation helpful? Give feedback.
-
Description
When inserting an image with Redactor, the image does not have width and height attributes. Those are important to prevent the content from jumping around while it loads, especially with lazyloaded images.
Steps to reproduce
Beta Was this translation helpful? Give feedback.
All reactions