diff --git a/lnbits/extensions/market/templates/market/_dialogs.html b/lnbits/extensions/market/templates/market/_dialogs.html
index d2a8dd0a..a0ab84b3 100644
--- a/lnbits/extensions/market/templates/market/_dialogs.html
+++ b/lnbits/extensions/market/templates/market/_dialogs.html
@@ -55,8 +55,16 @@
>
-
+
+
- Link to pass to stall relay
+ Disabled: link to pass to stall relays when using
+ nostr
{{ col.value }}
diff --git a/lnbits/extensions/market/templates/market/index.html b/lnbits/extensions/market/templates/market/index.html
index ffcb612b..77e3acce 100644
--- a/lnbits/extensions/market/templates/market/index.html
+++ b/lnbits/extensions/market/templates/market/index.html
@@ -498,6 +498,7 @@
},
productDialog: {
show: false,
+ url: true,
data: {}
},
stallDialog: {
@@ -536,6 +537,9 @@
methods: {
resetDialog(dialog) {
this[dialog].show = false
+ if (dialog == 'productDialog') {
+ this[dialog].url = true
+ }
this[dialog].data = {}
},
toggleDA(value, evt) {
@@ -798,11 +802,17 @@
var link = _.findWhere(self.products, {id: linkId})
self.productDialog.data = _.clone(link._data)
- self.productDialog.data.categories = self.productDialog.data.categories.split(
- ','
- )
+ if (self.productDialog.data.categories) {
+ self.productDialog.data.categories = self.productDialog.data.categories.split(
+ ','
+ )
+ }
+ if (self.productDialog.data.image.startsWith('data:')) {
+ self.productDialog.url = false
+ }
self.productDialog.show = true
+ console.log(self.productDialog)
},
sendProductFormData: function () {
let _data = {...this.productDialog.data}
@@ -831,14 +841,8 @@
let canvas = document.createElement('canvas')
canvas.setAttribute('width', fit.width)
canvas.setAttribute('height', fit.height)
- await pica.resize(image, canvas, {
- quality: 0,
- alpha: true,
- unsharpAmount: 95,
- unsharpRadius: 0.9,
- unsharpThreshold: 70
- })
- this.productDialog.data.image = canvas.toDataURL()
+ output = await pica.resize(image, canvas)
+ this.productDialog.data.image = output.toDataURL('image/jpeg', 0.4)
this.productDialog = {...this.productDialog}
}
},
diff --git a/lnbits/extensions/market/views_api.py b/lnbits/extensions/market/views_api.py
index 045bc0fc..31703e8d 100644
--- a/lnbits/extensions/market/views_api.py
+++ b/lnbits/extensions/market/views_api.py
@@ -113,6 +113,23 @@ async def api_market_product_create(
if stall.currency != "sat":
data.price *= settings.fiat_base_multiplier
+ if data.image:
+ image_is_url = data.image.startswith("https://") or data.image.startswith(
+ "http://"
+ )
+
+ if not image_is_url:
+
+ def size(b64string):
+ return int((len(b64string) * 3) / 4 - b64string.count("=", -2))
+
+ image_size = size(data.image) / 1024
+ if image_size > 100:
+ raise HTTPException(
+ status_code=HTTPStatus.BAD_REQUEST,
+ detail=f"Image size is too big, {int(image_size)}Kb. Max: 100kb, Compress the image at https://tinypng.com, or use an URL.",
+ )
+
if product_id:
product = await get_market_product(product_id)
if not product: