Image & File fields: Improved JS to better handle library option

Signed-off-by: Elliot Condon <e@elliotcondon.com>