Skip to content

Commit 11e18a0

Browse files
Openblocks-docsgitbook-bot
Openblocks-docs
authored andcommitted
GitBook: [#93] add doc "Image"
1 parent b0261e1 commit 11e18a0

File tree

7 files changed

+48
-0
lines changed

7 files changed

+48
-0
lines changed

docs/.gitbook/assets/image-1.png

346 KB
Loading

docs/.gitbook/assets/image-2.png

384 KB
Loading

docs/.gitbook/assets/image-3.png

419 KB
Loading

docs/.gitbook/assets/image-4.png

313 KB
Loading

docs/.gitbook/assets/image-5.png

285 KB
Loading

docs/SUMMARY.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
* [Temporary state](build-apps/write-javascript/temporary-state.md)
3030
* [Component guides](build-apps/component-guides/README.md)
3131
* [Option lists](build-apps/component-guides/option-lists.md)
32+
* [Image](build-apps/component-guides/image.md)
3233
* [Use Markdown](build-apps/component-guides/use-markdown.md)
3334
* [Module](build-apps/module.md)
3435
* [Navigation](build-apps/navigation.md)
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# Image
2+
3+
Use the **Image** component to present information in your apps in a vivic way. Openblocks supports you adding an image via URL and base64 encoded data.
4+
5+
## URL
6+
7+
Drag the **Image** component onto the canvas or into a **Container**. Click the **Image** component, and the **Properties** tab is displayed on the right. You can set the URL to display an image.
8+
9+
<figure><img src="../../.gitbook/assets/image-1.png" alt=""><figcaption></figcaption></figure>
10+
11+
## Base64 encoded data
12+
13+
You can also insert an image via base64 encoded data. Ensure that the encoded image source starts with `data:image/PICTURE_FORMAT;base64,` or simply`data:image;base64,`.
14+
15+
{% hint style="warning" %}
16+
Don't miss the comma at the end of the prefix:
17+
18+
<mark style="background-color:yellow;">`data:image/PICTURE_FORMAT;base64`</mark><mark style="background-color:yellow;">**`,`**</mark><mark style="background-color:yellow;">`YOUR_BASE64_ENCODED_IMAGE_DATA`</mark>
19+
20+
<mark style="background-color:yellow;">`data:image;base64`</mark><mark style="background-color:yellow;">**`,`**</mark><mark style="background-color:yellow;">`YOUR_BASE64_ENCODED_IMAGE_DATA`</mark>
21+
{% endhint %}
22+
23+
<figure><img src="../../.gitbook/assets/image-2.png" alt=""><figcaption></figcaption></figure>
24+
25+
### Demo: upload and display an image
26+
27+
One common use case for base64 image display would be combining a **File Upload** component with an **Image** component.
28+
29+
<figure><img src="../../.gitbook/assets/image-3.png" alt=""><figcaption></figcaption></figure>
30+
31+
Here is JS code that concatenates the prefix with the encoded base64 data of the uploaded file via `file1.value[0]`.
32+
33+
```javascript
34+
{{"data:image/jpeg;base64," + file1.value[0]}}
35+
```
36+
37+
## Set click preview for an image
38+
39+
Toggle **Support click preview** in the **Properties** tab to allow users to preview the image in its full size. Hover your mouse over the image, and you see **👁 Preview**. Then, you can click to preview.
40+
41+
<figure><img src="../../.gitbook/assets/image-4.png" alt=""><figcaption></figcaption></figure>
42+
43+
## Set the style of an image
44+
45+
In **Properties** > **Style**, change border color and set **Border radius** in pixels or by percentage.
46+
47+
<figure><img src="../../.gitbook/assets/image-5.png" alt=""><figcaption></figcaption></figure>

0 commit comments

Comments
 (0)