mirror of
https://github.com/sysadminsmedia/homebox.git
synced 2025-12-21 13:23:14 +01:00
Change Item Card to use object contain by default for images (#1020)
* feat: add legacy image fit preference and adjustable image display in card component * feat: add blurred bg image when object contain * fix: add alt text for image and improve objectContain
This commit is contained in:
@@ -10,7 +10,21 @@
|
||||
</div>
|
||||
<NuxtLink :to="`/item/${item.id}`">
|
||||
<div class="relative h-[200px]">
|
||||
<img v-if="imageUrl" class="h-[200px] w-full object-cover shadow-md" loading="lazy" :src="imageUrl" alt="" />
|
||||
<img
|
||||
v-if="imageUrl && objectContain"
|
||||
class="absolute h-[200px] w-full object-cover blur-md"
|
||||
loading="lazy"
|
||||
:src="imageUrl"
|
||||
alt=""
|
||||
/>
|
||||
<img
|
||||
v-if="imageUrl"
|
||||
class="absolute h-[200px] w-full shadow-md"
|
||||
:class="objectContain ? 'object-contain' : 'object-cover'"
|
||||
loading="lazy"
|
||||
:src="imageUrl"
|
||||
:alt="item.name"
|
||||
/>
|
||||
<div class="absolute inset-x-1 bottom-1">
|
||||
<Badge class="text-wrap bg-secondary text-secondary-foreground hover:bg-secondary/70 hover:underline">
|
||||
<NuxtLink v-if="item.location" :to="`/location/${item.location.id}`">
|
||||
@@ -76,6 +90,7 @@
|
||||
import { Checkbox } from "@/components/ui/checkbox";
|
||||
|
||||
const api = useUserApi();
|
||||
const preferences = useViewPreferences();
|
||||
|
||||
const imageUrl = computed(() => {
|
||||
if (!props.item.imageId) {
|
||||
@@ -109,6 +124,8 @@
|
||||
},
|
||||
});
|
||||
|
||||
const objectContain = computed(() => imageUrl.value !== "/no-image.jpg" && !preferences.value.legacyImageFit);
|
||||
|
||||
const locationString = computed(
|
||||
() => props.locationFlatTree.find(l => l.id === props.item.location?.id)?.treeString || props.item.location?.name
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user