erdfisch Blog

New module: Image widget default image

Single image: 
Body: 

As part of a client project we recently had the requirement of displaying an image field's default image in the node add form, before the user had uploaded a picture. This seemed simple enough to implement but thinking about it I realized this was quite a generic feature request and that such a module might prove useful for others. Rather by accident I even noticed that Drupal.org itself employs the same feature on user profile pages.

Thus, I hereby present the Image widget default image module, which does just that: If you have provided a default image for an image field and the user has not yet uploaded an image for that field, it displays that default image as a preview. Not many bells or whistle, but it works. (I can claim that, because it comes with tests. ;-)) If it does not work for you or if you have any questions please leave a comment or open an issue on Drupal.org.

Kommentare

Comments

Nice! Did you take a look at …

Nice! Did you take a look at drupal.org's code to see how they are doing it?

In reply to by loopduplicate (anonym)

Nope …

No, I did not. But I assume that Drupal.org is actually using the core User picture functionality that Drupal core ships with instead of a custom image field (although I did not check). This module only works with image fields.