Skip to content

mediaInputHelper does not process attached thumb #1047

Closed
@ParachainsDev

Description

@ParachainsDev

Need to add code to Request.php method:

private static function mediaInputHelper($item, &$has_resource, array &$multipart)
    {
...
foreach ($item as $media_item) {
...
<-- to put here -->
}

}

Code to add:

            if (!empty($thumb)) {

                // Allow absolute paths to local files.
                if (is_string($thumb) && file_exists($thumb)) {
                    $thumb = new Stream(self::encodeFile($thumb));
                }

                if (is_resource($thumb) || $thumb instanceof Stream) {
                    $has_resource = true;
                    $rnd_key      = uniqid('media_', false);
                    $multipart[]  = ['name' => $rnd_key, 'contents' => $thumb];

                    // We're literally overwriting the passed media data!
                    $media_item->thumb             = 'attach://' . $rnd_key;
                    $media_item->raw_data['thumb'] = 'attach://' . $rnd_key;
                }
              
            }

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions