the attachment page should have canonical added to the main post
on attachment page (image.php) I currently have (automatically added by All in One Seo Pack):
<link rel="canonical" href="https://example.com/main-post/image-name" />
And I want to change it to point to the post (where this image is attached)
<link rel="canonical" href="https://example.com/main-post" />
You can ignore All in One Seo Pack if that is difficutl to change, and maybe simple provide a way to add the canonical to the main post.