ruby - Rails - Image_tag alternative image -
whats best way create image_tag(via rails helper) displays image if default 1 broken instead of text. doesn't have support recursion. have default image want use if link broken.
you can via js, here shown jquery:
$('img').error(function() { $(this).attr('src', 'missing.png'); }); if it's specific image attach error handler object.
i don't know of way via image_tag helper; you'd have make request app src url , check error. i'd make sure that's need before going down road, though, depends on requirements.
Comments
Post a Comment