Update getDescription logic in AlttextAi.php

Created on 3 July 2024, 5 months ago
Updated 23 July 2024, 4 months ago

Problem/Motivation

In AlttextAi::getDescription() When `$path` is empty but `ALTTEXT_AI_FORCE_IMAGE_UPLOAD` is not set, the logic breaks down and attempts to base64_encode a boolean `FALSE`.

Steps to reproduce

Proposed resolution

Change

`if(empty($path) && !empty(getenv('ALTTEXT_AI_FORCE_IMAGE_UPLOAD'))) {`

to

`if(empty($path) || !empty(getenv('ALTTEXT_AI_FORCE_IMAGE_UPLOAD'))) {`

If either condition in the if statement is true, then we should go forth, to prevent passing `FALSE` to file_get_contents and ultimately to base64_encode.

🐛 Bug report
Status

Fixed

Version

2.0

Component

Code

Created by

🇬🇧United Kingdom Baysaa

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024