Make width optional for getThumbnail function

This commit is contained in:
2020-03-26 19:49:15 +01:00
parent 5defbcfad6
commit 9feafe70fc

View File

@@ -6,6 +6,7 @@ import { apiEndpoints } from './store'
*/
export const getThumbnail = (id, width, height, type = 'crop', quality = 75) => {
const ratio = 1.5
width = !width ? Math.round(height * ratio) : width
height = !height ? Math.round(width / ratio) : height
return `${apiEndpoints.rest}/assets/${id}?w=${width}&h=${height}&f=${type}&q=${quality}`
}