[Question] Adding image sizes to image
See original GitHub issueWhen I add an image attribute to the page I noticed that inside of the component the image has attributes to it.
When I call my images into the asset manager I do it like the following:
type: 'image',
src: 'http://placehold.it/350x250/459ba8/fff/image2.jpg',
height: 350,
width: 250
However, the height and width aren’t available when the image gets added to the canvas. I’ve tried to get the sizes by doing:
component.views[0].el.height
and adding it to the object, but every time I try I get 0 because the image isn’t available in the DOM yet, so it doesn’t know what size it is.
Is there a way to pass these heights and widths to the image, I need this for some lazy load functions I’m doing. I’m currently doing this on an update
editor.on('component:update', component => {
const item = component.attributes.attributes;
// item['width'] = component.view.el.width;
// item['height'] = component.view.el.height;
console.log(editor.AssetManager.getAll());
console.log('Comp:', component.views[0].el.height);
//console.log(image.naturalWidth);
});
Should i be adding to the attributes earlier than this?
Thanks.
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
Image sizes - Help Center - Typeform
Images uploaded to the Picture Choice question will be resized to fit depending on the size option you select when adding the question....
Read more >How to Create Additional Image Sizes in WordPress
Step by step guide showing how to easily add additional image sizes in WordPress themes and post content by utilizing the WordPress built-in ......
Read more >Image rating settings | QuestionPro Help Document
The image sizes include - auto-size to window, small, medium, large, and custom. You can also set an image size (width and height)...
Read more >Change your picture size - Microsoft Support
Change the size of your pictures in Microsoft Forms by making them larger, smaller, or zooming in to see just one part of...
Read more >Image Sizes in Typeform - YouTube
Typeform lets you add images, icons, and GIFs to questions. Whether as an answer option, or as part of the design, beautify your...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@awaredigital probably the best solution would be to follow the suggestion to listen up to
src
changes, then find the right asset and update attributes accordinglyThank you for that, it makes sense. But, I can’t see how to get the attributes of the image from the asset manager. When I try to access it, it’s always data from the “image” are they available in the model?
And this:
Always returns 0 as a value.