diff --git a/resources/js/components/SMCarouselSlide.vue b/resources/js/components/SMCarouselSlide.vue index 0db93cd..1b25467 100644 --- a/resources/js/components/SMCarouselSlide.vue +++ b/resources/js/components/SMCarouselSlide.vue @@ -1,7 +1,5 @@ diff --git a/resources/js/views/EventView.vue b/resources/js/views/EventView.vue index 3d5b1d9..4c0fffd 100644 --- a/resources/js/views/EventView.vue +++ b/resources/js/views/EventView.vue @@ -122,7 +122,7 @@ import SMMessage from "../components/SMMessage.vue"; import { api } from "../helpers/api"; import { Event, EventResponse, MediaResponse } from "../helpers/api.types"; import { SMDate } from "../helpers/datetime"; -import { imageLoad } from "../helpers/image"; +import { imageLoad, imageXXLarge } from "../helpers/image"; import { stringToNumber } from "../helpers/string"; import { useApplicationStore } from "../store/ApplicationStore"; @@ -312,7 +312,7 @@ const handleLoadImage = async () => { const data = result.data as MediaResponse; if (data && data.medium) { - imageLoad(data.medium.url, (url) => { + imageLoad(imageXXLarge(data.medium.url), (url) => { imageUrl.value = url; }); } diff --git a/resources/js/views/PostView.vue b/resources/js/views/PostView.vue index 2af9234..a2fe2f4 100644 --- a/resources/js/views/PostView.vue +++ b/resources/js/views/PostView.vue @@ -4,7 +4,9 @@ full class="sm-page-post-view" :page-error="pageError"> -
+

{{ post.title }}

@@ -34,6 +36,7 @@ import { UserResponse, } from "../helpers/api.types"; import { SMDate } from "../helpers/datetime"; +import { imageLoad, imageXXLarge } from "../helpers/image"; import { useApplicationStore } from "../store/ApplicationStore"; const applicationStore = useApplicationStore(); @@ -56,14 +59,41 @@ let pageLoading = ref(false); /** * Post styles. */ -let styleObject = {}; +const imageUrl = ref(""); /** * Post user. */ let postUser: User | null = null; -const loadData = async () => { +/** + * Load the hero image. + */ +const handleLoadImage = async () => { + api.get({ + url: "/media/{medium}", + params: { + medium: post.value.hero, + }, + }) + .then((result) => { + const data = result.data as MediaResponse; + + if (data && data.medium) { + imageLoad(imageXXLarge(data.medium.url), (url) => { + imageUrl.value = url; + }); + } + }) + .catch(() => { + /* empty */ + }); +}; + +/** + * Load the page data. + */ +const handleLoad = async () => { let slug = useRoute().params.slug || ""; pageLoading.value = true; @@ -88,6 +118,7 @@ const loadData = async () => { }).format("yyyy/MM/dd HH:mm:ss"); applicationStore.setDynamicTitle(post.value.title); + handleLoadImage(); // Get hero image try { @@ -101,9 +132,8 @@ const loadData = async () => { const mediumData = mediumResult.data as MediaResponse; if (mediumData && mediumData.medium) { - styleObject[ - "backgroundImage" - ] = `url('${mediumData.medium.url}')`; + const url = imageXXLarge(mediumData.medium.url); + styleObject["backgroundImage"] = `url('${url}')`; } } catch { /* empty */ @@ -143,7 +173,7 @@ const formattedPublishAt = (dateStr) => { return new SMDate(dateStr, { format: "yMd" }).format("MMMM d, yyyy"); }; -loadData(); +handleLoad();