Skip to content

Commit

Permalink
Merge pull request #2 from Cole-T-Harris/fix-image-overflow
Browse files Browse the repository at this point in the history
Fixes #1: Prevent overflow of image
  • Loading branch information
mesak authored Nov 29, 2024
2 parents 30782eb + 659155f commit 8b48daf
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 1.0.4 (release)

adjust image responsive scaling

## 1.0.3 (release)

add workflow
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mesak-imagesave-panel",
"version": "1.0.3",
"version": "1.0.4",
"description": "Image Save Panel Plugin for Grafana",
"scripts": {
"build": "grafana-toolkit plugin:build",
Expand Down
10 changes: 9 additions & 1 deletion src/ImageSavePanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,16 @@ export const ImageSavePanel: React.FC<Props> = ({ options, width, height }) => {
let { image: imageContext }: ImageData = options.context;
const imageAttr: any = {};
if (options.showIsResponsive) {
imageAttr.width = picWidth;
const windowAspectRatio = picWidth / picHeight;
const imageAspectRatio = options.context.width / options.context.height;

if (imageAspectRatio > windowAspectRatio) {
imageAttr.width = picWidth;
} else {
imageAttr.width = picHeight * imageAspectRatio;
}
if (!options.showIsRatio) {
imageAttr.width = picWidth;
imageAttr.height = picHeight;
}
}
Expand Down

0 comments on commit 8b48daf

Please sign in to comment.