Problem/Motivation

In #2756745: [Docs] Make media name optional and let media type plugins provide the default Media entity added support for default media name on type plugins. There is default implementation in the base class, but it would make sense to provide better defaults.

See #2762099: Provide default value for entity label, if needed. for example implementation in Image plugin.

Proposed resolution

There seems to be no good default for Slideshows. Maybe a label of first slide or something involving count of slides.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

slashrsm created an issue. See original summary.

marcoscano’s picture

Status: Active » Needs review
FileSize
11.5 KB
690 bytes

Yes, it is hard to imagine a more meaningful name than the base class default, in this case.

I don't know if we can use labels from the slides because the slides themselves can be anything, will they always have a meaningful label?

What about using timestamp + number of slides?

slideshow default name

slashrsm’s picture

Status: Needs review » Needs work
+++ b/src/Plugin/MediaEntity/Type/Slideshow.php
@@ -121,4 +121,18 @@ class Slideshow extends MediaTypeBase {
+    if (!empty($length)) {
+      return $media->getCreatedTime() . ' - ' . $length . ' slides';
+    }

If we go down the timestamp route I think we should format it. Also, this should go through t().

marcoscano’s picture

Status: Needs work » Needs review
FileSize
799 bytes
865 bytes

Sure! What about this option?

slashrsm’s picture

Status: Needs review » Fixed

Committed. Thanks!

  • slashrsm committed 8388c1b on 8.x-1.x authored by marcoscano
    Issue #2762215 by marcoscano, slashrsm: Provide default media name for...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.