Avoid JS errors when edit image is not available, such as outside of post editing.

props gcorne.
fixes #27551.


git-svn-id: https://develop.svn.wordpress.org/trunk@27787 602fd350-edb4-49c9-b593-d223f7449a82
Move counting of attachments for audio/video to the backend, instead of using a `reduce` function in JS.

See #27554.



git-svn-id: https://develop.svn.wordpress.org/trunk@27788 602fd350-edb4-49c9-b593-d223f7449a82