MerginMaps / docs

Documentation repository for merginmaps.com/docs
https://merginmaps.com/docs
Creative Commons Attribution 4.0 International
12 stars 15 forks source link

Preview of online images in the form through HTMLWidget #382

Closed saberraz closed 6 months ago

saberraz commented 7 months ago

In MM mobile 2.4.1, we have support for HTMLWidget. You can add a preview of the image in the form: image (6)

Feel free to improve and use the example project here: https://app.merginmaps.com/projects/lutraconsulting/image-html-view/

image

PeterPetrik commented 7 months ago

This is good to link to mergin-media-sync docs - if user transfers image to minio with this widget he can see it in the form and also add some examples to widget setup, maybe howto?

imagine you have textfield with name Text with value https://lh3.googleusercontent.com/p/AF1QipPJA1W3rAPK3xAArAOtYdTMu5rgRDbkTAotGV3t

To show small image:

<script>document.write(expression.evaluate("'<img src=\"'||attribute( @feature, 'Text' )||'\"\>'"));</script>

To show URL LINK that will open image in browser:

<script>document.write(expression.evaluate("'<a href=\"'||attribute( @feature, 'Text' )||'\">LINK</a>'"));</script>

To show mini image where on image click you see image in browser

<script>document.write(expression.evaluate("'<a href=\"'||attribute( @feature, 'Text' )||'\"><img src=\"'||attribute( @feature, 'Text' )||'\" height=200px width=300px></a>'"));</script>

alternatively if you want to keep aspect ratio of image

<script>document.write(expression.evaluate("'<a href=\"'||attribute( @feature, 'Text' )||'\"><img src=\"'||attribute( @feature, 'Text' )||'\" width=300px></a>'"));</script>

This works on both Mobiles and QGIS Desktop