mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 17:59:23 -04:00
* Fixed typo and increased performance. Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> # Conflicts: # src/plugins/expression_repeat_image/public/components/repeat_image_component.tsx
This commit is contained in:
parent
95115453a0
commit
63bac2e2a6
1 changed files with 8 additions and 4 deletions
|
@ -46,8 +46,10 @@ function setImageSize(img: HTMLImageElement, size: number) {
|
|||
}
|
||||
|
||||
function createImageJSX(img: HTMLImageElement | null) {
|
||||
if (!img) return null;
|
||||
const params = img.width > img.height ? { heigth: img.height } : { width: img.width };
|
||||
if (!img) {
|
||||
return null;
|
||||
}
|
||||
const params = img.width > img.height ? { height: img.height } : { width: img.width };
|
||||
return <img src={img.src} {...params} alt="" />;
|
||||
}
|
||||
|
||||
|
@ -80,12 +82,14 @@ function RepeatImageComponent({
|
|||
|
||||
if (image) {
|
||||
setImageSize(image, size);
|
||||
times(count, () => imagesToRender.push(createImageJSX(image)));
|
||||
const imgJSX = createImageJSX(image);
|
||||
times(count, () => imagesToRender.push(imgJSX));
|
||||
}
|
||||
|
||||
if (emptyImage) {
|
||||
setImageSize(emptyImage, size);
|
||||
times(max - count, () => imagesToRender.push(createImageJSX(emptyImage)));
|
||||
const imgJSX = createImageJSX(emptyImage);
|
||||
times(max - count, () => imagesToRender.push(imgJSX));
|
||||
}
|
||||
|
||||
return (
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue