I'm wanting to add a URL link into the image upload error message, but it's only printing the string, not adding the hyperlink. I'm using the code below
function my_max_image_size( $file ) {
$size = $file['size'];
$size = $size / 1024;
$type = $file['type'];
$is_image = strpos( $type, 'image' ) !== false;
$limit = 750;
$link = '<a href="example.com">';
$limit_output = '750kb';
if ( $is_image && $size > $limit ) {
$file['error'] = 'Image files must be smaller than ' . $limit_output . '<a href="example.com"> Click here to get help</a> ';
// not working either
// if ( $is_image && $size > $limit ) {
// $file['error'] = 'Image files must be smaller than ' . $limit_output . 'Click here to get help: '.$link.' </a> ';
}
return $file;
}
add_filter( 'wp_handle_upload_prefilter', 'my_max_image_size' );
I've also tried with using $var and sprintf, echo, printr but nothing seems to work.