if you have found a plugin that does what you’re looking for then i would suggest using that. Changes were made in the Gutenberg editor that makes any code i have obsolete. Also a lot of SEO plugins, like Yoast are recommending not to use image title attributes.