1) {
// Size selector available
?>
jQuery('select#format').change(function() {
const picker = jQuery('select#size');
updateDownloadLink('', picker.val(), picker);
});
jQuery('select#profile').change(function() {
const picker = jQuery('select#size');
updateDownloadLink('', picker.val(), picker);
});
jQuery('select#format').change(function() {
updateDownloadLink(
'',
'',
jQuery('.Picker #sizeInfo')
);
});
jQuery('select#profile').change(function() {
updateDownloadLink(
'',
'',
jQuery('.Picker #sizeInfo')
);
});
leave alone, no action required
- Terms and Download usage - href -> the URL of interest is inside the "url" query string param.
*/
?>
console.debug('HookFormat_chooserViewAppend_to_updateDownloadLink_js specific logic ...');
const format = jQuery('select#' + ns + 'format').find(":selected").val().toLowerCase();
const profile = jQuery('select#' + ns + 'profile').find(":selected").val();
console.debug('HookFormat_chooserViewAppend_to_updateDownloadLink_js: format = %o', format);
console.debug('HookFormat_chooserViewAppend_to_updateDownloadLink_js: profile = %o', profile);
// Example (final) regex (simplified): /^directDownload\('(https\:\/\/localhost\S*)', this\)$/m
const direct_dld_regex = new RegExp("^directDownload\\('(\\:\\\/\\\/\\S*)', this\\)$", 'm');
const dld_btn_onclick = download_btn.attr('onclick');
const dld_btn_href = download_btn.attr('href');
if (dld_btn_href === '#' && direct_dld_regex.test(dld_btn_onclick)) {
const orig_url = direct_dld_regex.exec(dld_btn_onclick)[1];
let format_chooser_modified = new URL(orig_url);
format_chooser_modified.searchParams.set('ext', format);
if (profile) {
format_chooser_modified.searchParams.set('profile', profile);
}
download_btn.attr('onclick', dld_btn_onclick.replace(orig_url, format_chooser_modified.toString()));
} else if (
dld_btn_href.startsWith('')
|| dld_btn_href.startsWith('')
) {
const orig_url = new URL(dld_btn_href);
let format_chooser_modified = new URL(dld_btn_href);
let inner_url = new URL(orig_url.searchParams.get('url'));
inner_url.searchParams.set('ext', format);
if (profile) {
inner_url.searchParams.set('profile', profile);
}
format_chooser_modified.searchParams.set('url', inner_url.toString());
download_btn.prop('href', dld_btn_href.replace(orig_url, format_chooser_modified.toString()));
}
$size_info['width'], 'height' => $size_info['height']];
}
foreach ($sizes as $id => $size_data) {
// File has not been generated for this size already so it will be missing data on the dimensions
if($size_data['width'] == 0 && $size_data['height'] == 0) {
if ($preview_sizes[$id]['width'] >= $original_width && $preview_sizes[$id]['height'] >= $original_height) {
$sizes[$id]['width'] = $original_width;
$sizes[$id]['height'] = $original_height;
} else {
$widthsf = $preview_sizes[$id]['width'] / $original_width;
$heightsf = $preview_sizes[$id]['height'] / $original_height;
$scale_factor = min($widthsf, $heightsf);
$sizes[$id]['width'] = round($original_width * $scale_factor);
$sizes[$id]['height'] = round($original_height * $scale_factor);
}
$mp = compute_megapixel($sizes[$id]['width'], $sizes[$id]['height']);
$sizes[$id]['html']['size_info'] = "{$sizes[$id]['width']} × {$sizes[$id]['height']} " . escape($lang['pixels']) . " ({$mp} " . escape($lang['megapixel-short']) . ")
";
if (!isset($resource['extension']) || !in_array(strtolower($resource['extension']), $ffmpeg_supported_extensions)) {
compute_dpi($sizes[$id]['width'], $sizes[$id]['height'], $dpi, $dpi_unit, $dpi_w, $dpi_h);
$sizes[$id]['html']['size_info'] .= sprintf(
'%1$s %2$s × %3$s %2$s %4$s %5$s %6$s
',
(int) $dpi_w,
escape($dpi_unit),
(int) $dpi_h,
escape($lang['at-resolution']),
(int) $dpi,
escape($lang['ppi'])
);
}
}
}
return $sizes;
}
function HookFormat_chooserViewModifycheckifexists() : bool
{
return true;
}