Can't get default media working

Created on 11 April 2025, 7 days ago

Problem/Motivation

I think I have tried pretty much everything there is around configuring default media images, so far without success. I understand that in core we can add default images for simple image field types or predefine a media image as default source for the media field, which however only works for new nodes and the images has to be removed again when finally setting the field with value.
But work for me but are not the solution I am looking for. Is there a way to make a media reference field having a default value that works the same way as for the image field, i.e. the field is not pre-populated. According to its name this module seems to solve this however I can't get it working.

Steps to reproduce

1. Add a media image field to the content type article.
2. In /admin/structure/types/manage/article/display select "Default image" as format.
3. Where would I set the default image? "How to use" doesn't say anything about this.

Proposed resolution

πŸ’¬ Support request
Status

Active

Version

1.0

Component

User interface

Created by

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @janc48
  • πŸ‡«πŸ‡·France ckhalilo

    Hi,
    Thank you for asking.

    Here’s how to configure and use the "Media Default Image" module:

    Configuration

    To configure the default image, go to the settings page: **`admin/config/media/default-image`**, and upload the image you want to set as the default.

    Usage

    • To use the default image in your content types, go to the **"Manage Display"** tab (for example: **`admin/structure/types/manage/article/display`**), select the **"Default Image"** format, and define the image style you want to apply.
    • The default image can also be used in **Views** by applying the format to the relevant fields.
  • All right, with that explanation it all makes sense. Unfortunately the default image is still not showing up in the article view. I did just like you said above. :(

  • Do you have any hints how to debug this issue?

  • πŸ‡«πŸ‡·France ckhalilo

    Hi,

    What version of drupal are you using?

    There are a problem of upload image file that i fixed in Drupal 11, you can use dev until the final version will be accepted by security advisory policy.
    https://www.drupal.org/project/media_default_image/releases/1.0.x-dev β†’ .

    Regards
    Khalil

  • Thank you for your reply.

    I am using Drupal 10.4.5. The dev Version didn't help, the default image is still not displayed. :(

  • πŸ‡«πŸ‡·France ckhalilo

    Hi,

    To assist you further, could you please explain the process that leads to the default image not being displayed?
    Additionally, could you provide screenshots or the steps so I can reproduce the same issue?

    Regards
    Khalil

  • Here is what I did:
    1. Install the module via composer and activate it.
    2. Set the default image in the configuration area

    3. Add a new media field to the content type "article".
    4. Set the format "Default image" for the display of this field.

    5. Leave the article's media field empty:

    6. Check if article has the default image displayed:

  • πŸ‡«πŸ‡·France ckhalilo

    Hi,

    have you try another image style to see?

    Regards
    Khalil

Production build 0.71.5 2024