-
-
Notifications
You must be signed in to change notification settings - Fork 10.8k
Added image counting to the {{reading_time}} helper #9366
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
issue #9200 - Added imageCount utility, which counts images using an img-tag regex, amended from the general tag-regex found in wordCount - Added this imageCount to the {{reading_time}} helper, adding 12 seconds to the reading time for every image - The feature image is still counted as before
Hi @rkalis! Thanks for taking the time to implement this. I wanted to flag up that the article referenced in #9200 recommends an algorithm where it adds 12 seconds for the first image, 11 for the second, 10 for the 3rd and so on. Would you mind updating your code to follow this pattern? Thanks again! |
…read-time-and-you-bc2048ab620c issue #9200 - The first image adds 12 seconds, the second 11, the third 10, and so on - Images from the tenth onwards add 3 seconds to the reading time - I thought about using a consecutive numbers sum algorithm to avoid writing a for loop, but I think this for loop keeps the code a lot more readable
I have a different commit ready for adding a reading speed (wpm) option to the helper, would you like it in the same PR, or should I open a new one (is it even still a wanted feature)? |
I added the commit for the wpm option, cleaned up the tests as well. Also made sure it has no conflicts with the changes made with the translatability changes. |
issue #9200 - Added a wpm option to the {{reading_time}} helper - Fixed word count of one test - Added a variable to the tests file which represents the article (250 words), since this can be used (with additions) by every test
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me from the code perspective. Have not tested it.
Really sorry for dropping the ball on this. Code looks good 👍 However, I would prefer not to include the wpm option for now. It was listed on the original issue as a potential future improvement, but it's the kind of thing I would only add if it was often-requested. So if it had been requested a lot, we would definitely add it, but so far I've not heard a single request for it. Every option adds maintenance & documentation overhead, and therefore it's best not to add anything unless we're certain it will be used. Other than that this is good to go IMO. |
issue #9200 - Removed the wpm feature from the reading time helper - Still kept the options initialisation in there, since it's also added in the i18n updates - Kept the tidied up tests as well
No worries, I understand it's a big project, there's a lot that needs attention :). Sounds logical to try to keep the amount of features limited to those that are actually being used. It won't be a lot of effort either to add it back in if it would be requested more often in the future 👍 . I pushed a rollback for the wpm feature, while keeping the changes made to the tests. |
Awesome, thanks for the understanding and for the help getting this implemented. I'll let @kirrg001 do the merge, releases are every Tuesday 😄 |
issue #9200