This tutorial describes the Image component usage in web applications.

Look & Feel

01_lookNfeel

  • Upload - it is possible to predefine an image by pressing the button and selecting an image from the file system;

1

  • Image alt [string] - also called alt tags and alt descriptions, alt text is the written copy that appears in place of an image on a webpage if the image fails to load on a user's screen. This text helps screen-reading tools describe images to visually impaired readers and allows search engines to better crawl and rank your website;
  • Width [string] - image width by default;
  • Height [string] - image height by default;
  • Visible [boolean] - defines if the image is visible or not;
  • Name [string] - component’s name;

Image in HTML is a reference to the image object itself. Therefore, Image always works with links and, in order to use image data, you need to get a link to it.

The following BPs are pregenerated for web applications usage:

  • Image Get Properties - gets image properties:
    • Component ID [string] - component’s identifier;
    • Width [string] - image width;
    • Height [string] - image height;
    • Image URL [string] - image URL-address;
    • Tooltip [string] - tooltip string to be shown on hover;
    • Visible [boolean] - defines if the image is visible or not;
    • Loading [boolean] - sets image into “loading” state if true;

03_getProperties

  • Image Set Properties - resets all the properties of  the selected image and sets the given ones instead:
    • Component ID [string] - component’s identifier;
    • Width [string] - image width;
    • Height [string] - image height;
    • Image URL [string] - image URL-address;;
    • Tooltip [string] - tooltip string to be shown on hover;
    • Visible [boolean] - defines if the image is visible or not;
    • Loading [boolean] - sets image into “loading” state if true;

04_setProperties

  • Image Update Properties -  updates image properties:
    • Component ID [string] - component’s identifier;
    • Width [string] - image width;
    • Height [string] - image height;
    • Image URL [string] - image URL-address;
    • Tooltip [string] - tooltip string to be shown on hover;
    • Visible [boolean] - defines if the image is visible or not;
    • Loading [boolean] - sets image into “loading” state if true;

05_updateProperties

Usage example

Consider an example of loading a user profile avatar. The web interface consists of an image and a button that triggers the BP, and looks like this:

06_example_ui

BP starts from onClick trigger. To pick the files from the user’s device filesystem Select Files block is used (Max files = 1, File types = Image). If the file is picked successfully array element with index=0 to be selected.

07_example_1

The resulting file element of the Files array must be uploaded to the web application server for further use (Server request POST /_files/). If the request is successful, the file object at the output of the Server request POST /_files/ block is passed to the input of the Expand file block to get its ID.

07_example_2

To get the URL, you need to take the file ID and convert its value to a string (To String). The relative file path  would be /api/_files/<ID>/download/. Thus, to upload an image, the file path has to be passed into the Image URL property of the Image Update Properties block.

07_example_3

Published application is on the example below

result

Was this article helpful?

AppMaster.io 101 Crash Course

10 modules
2 weeks

Not sure where to start? Get going with our crash course for beginners and explore AppMaster from A to Z.

Start Course
Development it’s so easy with AppMaster!

Need More Help?

Solve any issue with the help of our experts. Save time and focus on building your applications.

headphones

Contact Support

Tell us about your problem, and we’ll find you a solution.

message

Community Chat

Discuss questions with other users in our chat.

Join Community