How to remove status messages from admin theme? I am working with Drupal 8. I have enabled "Seven" as admin theme. When I have added an image with high resolution I am getting 2 error messages at a time(screenshot). I want to hide "green" colored status message from this particular page. I have tried with hook_page_attachments(array &amp;$attachments) in my custom module to include the css for admin theme.

But it is not working. How to solve this issue?

.
hook_page_attachments is not the correct hook. You want to implement hook_preprocess_HOOK, like the example below.

There are some caveats with this fix, especially if your site will be localized to other languages, see the comments within the code:

/**
 * Implements hook_preprocess_HOOK().
 * Implements hook_preprocess_status_messages().
 *
 * @param $variables
 */
function mymodule_preprocess_status_messages(&amp;$variables) {
  if (isset($variables['message_list']['status'])) {
    $status_messages = $variables['message_list']['status'];
    $dummy_message_parameter_1 = '_parameter_1_';
    $dummy_message_parameters =       [
      '%dimensions' =&gt; $dummy_message_parameter_1,
      '%new_width' =&gt; 0,
      '%new_height' =&gt; 0,
    ];
    // The message could change eventually, but it is unlikely.
    // This logic *could brake* in a some language translations, if the %dimensions string is not the first parameter.
    $file_resize_message = t('The image was resized to fit within the maximum allowed dimensions of %dimensions pixels. The new dimensions of the resized image are %new_widthx%new_height pixels.', $dummy_message_parameters);
    // $file_resize_message_start is the part of the message that won't vary.
    $file_resize_message_start =strtok((string)$file_resize_message, $dummy_message_parameter_1); ;
    foreach ($status_messages as $delta =&gt; $message) {
      if (strpos((string)$message, $file_resize_message_start) !== FALSE) {
        // The next commented line still leaves a green area
        // unset($variables['message_list']['status'][$delta]);
        // Removing all messages, the side effect is that you could be
        // missing on some relevant messages
        unset($variables['message_list']['status']);
      }
    }
  }
}


The message is set in the function file_validate_image_resolution at core/modules/file/file.module:447 (as of version 8.6.0-dev)

There is a good explanation about the hook implementation at Stack Overflow