a new picture shows as - for a person * the avatar's ('itflow-picture-photo' for a photo) * 'box' a photo's box - 'square' or 'wide' (4:3) * 'name' the form field with the person's name - their initials follow it */ function pictureField($name, $remove_name, $current, $empty, array $opts = []) { $round = !empty($opts['round']); $noun = $round ? 'picture' : 'photo'; $attributes = [ 'data-picture-field' => '', 'data-picture-title' => $opts['title'] ?? ucfirst($noun), 'data-picture-class' => $opts['class'] ?? 'itflow-picture-photo', 'data-picture-has' => $remove_name !== '' ? '1' : '', 'data-crop' => $opts['shapes'] ?? 'square', 'data-crop-max' => (string) intval($opts['max'] ?? ($round ? 512 : 2048)), 'data-crop-shape' => $round ? 'circle' : 'rect', 'data-picture-name' => (string) ($opts['name'] ?? ''), ]; $html = ''; foreach ($attributes as $attribute => $value) { $html .= ' ' . $attribute . '="' . escapeHtml($value) . '"'; } $box = $round ? 'is-round' : 'is-photo is-' . ($opts['box'] ?? 'square'); $label = escapeHtml("Change the $noun"); return '
' . '' . '' . '' . ($remove_name !== '' ? '' : '') . '
'; } /** A photo as a picture field shows it - $src already the page's path to it. HTML. */ function picturePhoto($src, $alt = '') { return '' . escapeHtml($alt) . ''; } /** What a photo's field shows without one - a camera and $text. HTML. */ function picturePhotoEmpty($text = 'Add a photo') { return '' . escapeHtml($text) . ''; }