Skip to content

Commit

Permalink
Larger element card thumbs + fix down/up-scaling bug
Browse files Browse the repository at this point in the history
Fixes #14866
  • Loading branch information
brandonkelly committed Apr 27, 2024
1 parent 1dc1923 commit b122c62
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 7 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG-WIP.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
- Unselected table column options are now sorted alphabetically within element indexes.
- Table views within element index pages are now scrolled directly, so that their horizontal scrollbars are always visible without scrolling to the bottom of the page. ([#14765](https://github.com/craftcms/cms/issues/14765))
- Element tooltips now appear after a half-second delay. ([#14836](https://github.com/craftcms/cms/issues/14836))
- Thumbnails within element cards are slightly larger.

### Administration
- Element conditions within field layout designers’ component settings now only list custom fields present in the current field layout. ([#14787](https://github.com/craftcms/cms/issues/14787))
Expand Down Expand Up @@ -34,3 +35,4 @@
- Batched queue jobs now set their progress based on the total progress across all batches, rather than just the current batch. ([#14817](https://github.com/craftcms/cms/pull/14817))
- Fixed a bug where ordering by a custom field would only partially work, if the custom field was included in multiple field layouts for the resulting elements. ([#14821](https://github.com/craftcms/cms/issues/14821))
- Fixed a bug where element conditions within field layout designers’ component settings weren’t listing custom fields which were just added to the layout. ([#14787](https://github.com/craftcms/cms/issues/14787))
- Fixed a bug where asset thumbnails within element cards were blurry. ([#14866](https://github.com/craftcms/cms/issues/14866))
4 changes: 3 additions & 1 deletion src/elements/Asset.php
Original file line number Diff line number Diff line change
Expand Up @@ -2144,7 +2144,9 @@ protected function thumbUrl(int $size): ?string
return null;
}

if ($this->getWidth() && $this->getHeight()) {
$forCard = $size % 128 === 0;

if (!$forCard && $this->getWidth() && $this->getHeight()) {
[$width, $height] = Assets::scaledDimensions((int)$this->getWidth(), (int)$this->getHeight(), $size, $size);
} else {
$width = $height = $size;
Expand Down
2 changes: 1 addition & 1 deletion src/helpers/Cp.php
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,7 @@ public static function elementCardHtml(ElementInterface $element, array $config
$headingContent = self::elementLabelHtml($element, $config, $attributes, fn() => Html::encode($element->getUiLabel()));
$bodyContent = $element->getCardBodyHtml() ?? '';

$thumb = $element->getThumbHtml(120);
$thumb = $element->getThumbHtml(128);
if ($thumb === null && $element instanceof Iconic) {
$icon = $element->getIcon();
if ($icon) {
Expand Down
2 changes: 1 addition & 1 deletion src/web/assets/cp/dist/css/cp.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/web/assets/cp/dist/css/cp.css.map

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions src/web/assets/cp/src/css/_main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3256,8 +3256,8 @@ table {
align-items: stretch;
margin: calc(var(--m) * -1);
@include margin-right(0);
width: 120px;
min-width: 120px; // needed for flex
width: 128px;
min-width: 128px; // needed for flex
min-height: calc(var(--m) * 2 + var(--lh) * 3 + var(--xs));
background-color: var(--gray-100);
overflow: hidden;
Expand Down Expand Up @@ -3294,7 +3294,7 @@ table {
img,
svg {
width: 100%;
max-height: 120px;
max-height: 128px;
object-fit: cover;
}
}
Expand Down

0 comments on commit b122c62

Please sign in to comment.