Fix cover image sampling not working when webview strips origin header, instead fetch image from server with CapacitorHttp

This commit is contained in:
advplyr
2026-05-10 15:15:13 -05:00
parent b8ac073247
commit 853546f3d2
5 changed files with 118 additions and 27 deletions
+6 -13
View File
@@ -13,7 +13,7 @@
</div>
</div>
<div class="relative" @click="showFullscreenCover = true">
<covers-book-cover :library-item="libraryItem" :width="coverWidth" :book-cover-aspect-ratio="bookCoverAspectRatio" no-bg raw @imageLoaded="coverImageLoaded" />
<covers-book-cover :library-item="libraryItem" :width="coverWidth" :book-cover-aspect-ratio="bookCoverAspectRatio" no-bg raw />
<div v-if="!isPodcast" class="absolute bottom-0 left-0 h-1 z-10 box-shadow-progressbar" :class="userIsFinished ? 'bg-success' : 'bg-yellow-400'" :style="{ width: coverWidth * progressPercent + 'px' }"></div>
</div>
</div>
@@ -172,7 +172,7 @@
<script>
import { Dialog } from '@capacitor/dialog'
import { AbsFileSystem, AbsDownloader } from '@/plugins/capacitor'
import { FastAverageColor } from 'fast-average-color'
import { getAverageColorFromCoverUrl } from '@/utils/coverAverageColor'
import cellularPermissionHelpers from '@/mixins/cellularPermissionHelpers'
export default {
@@ -496,17 +496,10 @@ export default {
},
async coverImageLoaded(fullCoverUrl) {
if (!fullCoverUrl) return
const fac = new FastAverageColor()
fac
.getColorAsync(fullCoverUrl)
.then((color) => {
this.coverRgb = color.rgba
this.coverBgIsLight = color.isLight
})
.catch((e) => {
console.log(e)
})
const avg = await getAverageColorFromCoverUrl(this, fullCoverUrl)
if (!avg) return
this.coverRgb = avg.rgba
this.coverBgIsLight = avg.isLight
},
moreButtonPress() {
this.showMoreMenu = true