Also check for the action being 'upload-attachment', as Weston suggested
Also check for the action being 'upload-attachment', as Weston suggested

This logic usually worked,
but it didn't apply to newly-uploaded images.

ampproject/amp-toolbox-php,ampproject/amp-toolbox-php