Skip to content

Usage

System Settings

All settings have the prefix randomphoto..

Setting Description Default
mediasource Media source containing the photos 1
folder Folder with the photos, relative to the root of the media source assets/images/randomphoto/
width Width of the background in pixels 1920
height Height of the background in pixels 1080
min_width Minimum width of the used photos, 0 for no minimum 0
min_height Minimum height of the used photos, 0 for no minimum 0
crop_path Folder for the resized photos in the media source crop/
interval Minutes until a new photo is chosen 1440
message Message at the top right of your photos

Folder

All photos in the folder and its subfolders are used. Hidden files and folders and the folder of the resized photos (crop_path) are skipped.

Warning

Large folders, especially on FTP or S3 media sources, slow down the login page, when the file list is created. The list is cached for one day, so added photos can take up to a day to appear. Use Manage > Clear Cache to use them immediately.

Size

The photo is cropped in the center to the aspect ratio of width and height and resized. Set one of them to 0 to resize without cropping, or both to 0 to use the original photo. Smaller photos are not enlarged. The resized photos are not removed automatically.

The minimum size is measured on the photo as it is displayed, i.e. with its rotation applied.

Interval

The default of 1440 minutes changes the photo daily at midnight server time. 60 changes it every hour and 0 on every page load, which also resizes the photo on every load. Use Manage > Clear Cache to choose a new photo immediately.

Message

The message is shown vertically at the top right of the photo. The word in front of it is the randomphoto.photos lexicon entry.

The lexicon entries can be changed in the MODX Manager under Manage → Lexicon Management, in the namespace randomphoto and the topic default.

Photo Message
Your photo randomphoto.message system setting, if filled
Your photo randomphoto.default_message lexicon entry, if it is empty
Demo photo randomphoto.demo_message lexicon entry

The message is processed by the MODX parser. [[+year]] is replaced with the current year and [[+site_name]] with the site name:

© [[+year]] <a href="https://example.com/" target="_blank">Your Name</a>

Only the tags a, br, i, em, b and strong with the attribute class are allowed, links additionally with href, target and rel. Links need a http, https or mailto URL.

Warning

The message is shown to visitors, who are not logged in. Only use trusted content, chunks and snippets in it.

Demo photo

The demo photo is shown, if the folder is not found, if it contains no photos, if all photos are smaller than the minimum size or if the media source could not be loaded. The reason is written to the MODX log.