utils
Table of Contents
Constants
- DEFAULT_IMAGE_NAME = "default.jpg"
Functions
- createEventUpdateLink() : string
- createEventDeleteLink() : string
- processUploadedImage() : bool
- Processes, resizes, and saves an uploaded image file.
Constants
DEFAULT_IMAGE_NAME
public
mixed
DEFAULT_IMAGE_NAME
= "default.jpg"
Functions
createEventUpdateLink()
createEventUpdateLink(mixed $event_id) : string
Parameters
- $event_id : mixed
Return values
stringcreateEventDeleteLink()
createEventDeleteLink(mixed $event_id) : string
Parameters
- $event_id : mixed
Return values
stringprocessUploadedImage()
Processes, resizes, and saves an uploaded image file.
processUploadedImage(string $source_path, int $image_type, string $target_dir, string $target_filename, int $target_width) : bool
This function handles the resizing of an image to a specified width while automatically calculating the height to maintain the original aspect ratio. It supports JPEG and PNG formats and preserves transparency for PNG images.
Parameters
- $source_path : string
-
The absolute path to the temporary source file (e.g., from $_FILES).
- $image_type : int
-
The GD image type constant (IMAGETYPE_JPEG or IMAGETYPE_PNG).
- $target_dir : string
-
The destination directory path (must include trailing slash).
- $target_filename : string
-
The name of the file to save (including extension).
- $target_width : int
-
The desired width of the resized image in pixels.
Return values
bool —True if the image was successfully processed and saved, false otherwise.