I have a array which store some base64 values like the one below:
"data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD ..."
I made this function:
var base64Matcher = new RegExp("^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=|[A-Za-z0-9+/]{4})$");
$.each(inputValues, function(key, value) {
if (base64Matcher.test(value)) {
$('#' + key).attr('src', value);
} else {
$('#' + key).val(value);
}
});
Based on this post but when I try to load values I get this error:
SecurityError: The operation is insecure
How did you test if value is base64 encode and then set the src
attribute right? Here is a image showing what holds inputValues
is just values I just found trough those values and if it's base64
encode then I set src
because that is a image, the function fails only when I load a image