LLMS_Generator_Courses::maybe_sideload_choice_image( array $choice, int $question_id )

Determines if a raw question choice object contains image data that should be sideloaded


Parameters Parameters

$choice

(array) (Required) Raw choice data array.

$question_id

(int) (Required) WP_Post ID of the parent question.


Top ↑

Return Return

(array) Choice data array.


Top ↑

Source Source

File: includes/class-llms-generator-courses.php

	protected function maybe_sideload_choice_image( $choice, $question_id ) {

		if ( empty( $choice['choice_type'] ) || 'image' !== $choice['choice_type'] || ! $this->is_image_sideloading_enabled() ) {
			return $choice;
		}

		$id = $this->sideload_image( $question_id, $choice['choice']['src'], 'id' );
		if ( is_wp_error( $id ) ) {
			return $choice;
		}

		$choice['choice']['id']  = $id;
		$choice['choice']['src'] = wp_get_attachment_url( $id );

		return $choice;

	}


Top ↑

Changelog Changelog

Changelog
Version Description
4.7.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.