An alternative solution which avoids adding an extra hidden input field would be to append a new class to the <input id="var_{{ field.name }}" element

<td><input id="var_{{ field.name }}" .... class="filer_image_url {% if optional_field %} optional {% endif %}"

Then, in image_fields.js, instead of 

if (jQuery(this).siblings("[name='_opt_"+ image_field_name +"']").length){

would be 

if (jQuery(this).hasClass("optional") {