Last active
November 9, 2018 09:06
-
-
Save mikeschinkel/6cd04424d202d96384d9fdd8ea5a3076 to your computer and use it in GitHub Desktop.
Number of seconds to read an image, per Medium's algorithm: https://blog.medium.com/read-time-and-you-bc2048ab620c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function image_reading_seconds( $count ) { | |
// Every image start with 3 seconds | |
$reading_seconds = $count * 3; | |
// The first 9 images also add the cumulative | |
// amount of seconds calculated by 10 seconds | |
// minus the image count for each image. | |
$reading_seconds += 9 >= $count | |
? 10 * $count - intval( ( $count**2 + $count ) / 2.0 ) | |
: 45; // 9 + 8 + 7 ... 3 + 2 + 1 | |
return $reading_seconds; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment