Not displaying reading timing properly if content is less than 1 min reading

Created on 9 January 2024, 6 months ago
Updated 22 February 2024, 4 months ago

Problem/Motivation

If the reading time is configured to display in minutes and seconds format (@minutes min @seconds sec read), and the content takes less time to read than a minute, it will still show as 1 min and 10 sec.

✨ Feature request
Status

Active

Version

1.0

Component

Code

Created by

🇺🇸United States Niralk

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

Comments & Activities

  • Issue created by @Niralk
  • 🇮🇳India sidharth_soman Bangalore

    The Mtownsend\ReadTime\ReadTime vendor package fixes the read time at 1 min for some reason. I introduced some custom logic to display the minutes correctly. Let me know if it works fine. I'll probably have to make some modifications to it. Here's the patch.

  • 🇺🇸United States mtalt Maryland

    @sidharth_soman This does appear to be a bug in Mtownsend\ReadTime\ReadTime in the calculateMinutes method. Ideally, the issue would be fixed in that repository.

    I do worry about this being an unexpected change for users of this module. There are likely many people that only use minutes in their field formatter and this fix would cause no read time to be displayed for short content. Perhaps the simple fix for this would be to check if the tokenized string only contains @minutes and if the minutes value is 0, then we change it to 1 so that "1 min read" is still shown? Or we could introduce a setting on the field formatter for a minimum read time of 1 minute.

    https://www.drupal.org/project/estimated_read_time/issues/3377947 ✨ Introduce switch to manually set read time Needs work could serve as a work-a-round by being able to manually set read times.

  • 🇺🇸United States mtalt Maryland

    Opened https://github.com/mtownsend5512/read-time/issues/20 to start the conversation of making a change to the package.

Production build 0.69.0 2024