set title attribute in wp_get_attachment_image()

In a relatively fresh install I can’t replicate the issue. When I post your code with my own image ID I get the title="My Custom Title" attribute.

It’s important to note however that the “Title” of an image in the media library is not output as a title attribute in the standard output of wp_get_attachment_image(). The “Title” is just the name of the listing in the media library. WordPress does not output a title attribute automatically, I think because it’s not considered a benefit for accessibility. By default it will only output the value of “Alt Text” as an alt attribute.

You should be able to set the attribute in wp_get_attachment_image() the way you have, however. If there is a title attribute being added without your intervention then a plugin or theme must be adding it with the wp_get_attachment_image_attributes filter. This filter is run after your attributes are assigned, so if there is a value you cannot overwrite in the attributes argument, then this would explain why.