Extensions/Authoring/imageUploader

Extensions add specific functionality to Learnosity APIs. They rely on modules within LT being available.

--

This extension replaces the default Learnosity image uploader with a custom image uploader that supports image editing and compression before uploading to the Learnosity CDN.

Consider this extension if you're looking to reduce the file size of images or if you want to give users the flexibility to crop or rotate them before uploading.

Supported mime types: image/gif, image/jpeg, image/png, image/svg+xml

.webp files are not supported by Learnosity, so we don't support them here.

Animated gifs become static.

By default, we resize images to a maximum width or height of 1500px. The calling page can override width, height, and quality. See below in run().

Image comparisons (before and after)

Click image to view full size.

Original Compressed File size reduction

205kB (2000x1589)

128kB (1500x1091)
37.56%

480kB (2584x1518)

305kB (1500x881)
36.46%

16.5mb (5102x2488)

155kB (1500x731)
99.06%

11.9mb (5098x2480)

97kB (1500x729)
99.18%

4.7mb (770x702)

50kB (770x702)
98.94%

Exclusions

This extension doesn't run inside the simple features dialog. This mainly impacts posters for video files and background images for audio files.

Methods

run(security, request, optionsopt)

Extension constructor. We require security and request from the Author API initialisation to be passed in.

Since
2.10.0
Example
import { LT } from '@caspingus/lt/src/authoring/core';
import * as imageUploader from '@caspingus/lt/src/authoring/extensions/ui/imageUploader/index';

LT.init(authorApp); // Set up LT with the Author API application instance variable

// Put individual extensions in the LT object if that makes your life easier
LT.extensions = {
    imageUploader,
};

LT.extensions.imageUploader.run(security, request);
Parameters:
Name Type Attributes Description
security object

The security object returned from the SDK.

request object

The request object returned from the SDK.

options object <optional>

Override for quality (value between 0 and 1), maxWidth (number), and maxHeight (number). Default values are 0.7, 1500, and 1500 respectively.