Skip to content

Commit fbd2e64

Browse files
committed
update scale image size
1 parent b40a203 commit fbd2e64

File tree

2 files changed

+23
-10
lines changed

2 files changed

+23
-10
lines changed

src/Plupload.php

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -296,17 +296,20 @@ protected function setWrapperStyle() {
296296
}
297297
$width = 480;
298298
$height = 300;
299-
if (isset($this->options['resize']) && !empty($resize = $this->options['resize'])) {
300-
$width = !isset($resize['width']) ?: $resize['width'];
301-
$height = !isset($resize['height']) ?: $resize['height'];
302-
}
303-
if (isset($this->wrapperOptions['width'])) {
304-
$width = (int) $this->wrapperOptions['width'];
299+
if (!empty($this->resize)) {
300+
$_w = ArrayHelper::getValue($this->resize, 'width');
301+
$_h = ArrayHelper::getValue($this->resize, 'height');
302+
if ($_w) {
303+
$width = $_w;
304+
}
305+
if ($_h) {
306+
$height = $_h;
307+
}
305308
}
306-
if (isset($this->wrapperOptions['height'])) {
307-
$height = (int) $this->wrapperOptions['height'];
309+
if ($width) {
310+
$scale = $height / $width * 100;
311+
Html::addCssStyle($this->htmlOptions, "--scalebox-ratio: {$scale}%;");
308312
}
309-
$this->htmlOptions['style'] = "width: {$width}px; height: {$height}px;";
310313
}
311314

312315
/**

src/assets/css/plupload.custom.css

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
/*Plupload*/
2+
:root {
3+
--scalebox-ratio: 61.8%;
4+
}
25

3-
.plupload_wrapper{
6+
.plupload_wrapper {
47
position: relative;
58
}
69
.plupload_preview,
@@ -164,7 +167,14 @@
164167
.plupload_wrapper.plupload_one{
165168
border: 1px dashed #ccc;
166169
}
170+
.plupload_wrapper.plupload_one:after{
171+
padding-top: var(--scalebox-ratio);
172+
content: "";
173+
width: 100%;
174+
display: block;
175+
}
167176
.plupload_one .plupload_container{
177+
position: absolute;
168178
width: 100%;
169179
height: 100%;
170180
}

0 commit comments

Comments
 (0)