Currently, the media for a page on
/hello-world/ is shown on
/hello-world/attachment/image-name/. Is it possible to remove
attachment from this URL, and make it
Don't include %category% anywhere in your custom permalink string, then it won't need the "attachment" text. Also, don't use numeric slugs for the page/post name. Same basic problem occurs there.
Try adding this code to your functions.php file as provided by TheDeadMedic: