// Clean up from previous test....
$courseformat->delete_image($sectionid, $contextid);
// This test....
$storedfilerecord = $courseformat->create_original_image_record($contextid, $sectionid, $imagefilename);
$sectionimage = $courseformat->get_image($courseid, $sectionid);
$courseformat->create_section_image($original, $storedfilerecord, $sectionimage);
$o .= html_writer::start_tag('div');
$o .= html_writer::tag('p', 'Original image resized to maximum width:');
$src = moodle_url::make_pluginfile_url($contextid, 'course', 'section', $sectionid, '/', $imagefilename);
$o .= html_writer::empty_tag('img', array('src' => $src, 'alt' => 'Grid Format Image Test Original Resized'));
$o .= html_writer::end_tag('div');
$o .= html_writer::start_tag('div');
$o .= html_writer::tag('p', 'Converted image to current course settings:');
$sectionimage = $courseformat->get_image($courseid, $sectionid);
$src = moodle_url::make_pluginfile_url($contextid, 'course', 'section', $sectionid, $courseformat->get_image_path(), $sectionimage->displayedimageindex . '_' . $sectionimage->image);
$o .= html_writer::empty_tag('img', array('src' => $src, 'alt' => 'Grid Format Image Test Converted to current course settings'));
$o .= html_writer::end_tag('div');
$currentsettings = $courseformat->get_settings();
$o .= html_writer::start_tag('div');
$o .= html_writer::tag('p', 'Current settings: ' . print_r($currentsettings, true));
$ratios = format_grid::get_image_container_ratios();
$resizemethods = array(1 => new lang_string('scale', 'format_grid'), 2 => new lang_string('crop', 'format_grid'));
$o .= html_writer::tag('p', 'Width: ' . $currentsettings['imagecontainerwidth']);
$o .= html_writer::tag('p', 'Ratio: ' . $ratios[$currentsettings['imagecontainerratio']]);
$o .= html_writer::tag('p', 'Resize method: ' . $resizemethods[$currentsettings['imageresizemethod']]);
$o .= html_writer::end_tag('div');
echo $o;
require_once 'test_footer.php';
// Remove original...
$original->delete();
unset($original);