Use derived-mode-p rather than checking major-mode directly.
Attach a file by drag & drop or click to upload