Support » Plugin: Worth The Read » Feature proposal: including figures (images) in reading time calculation

  • Resolved tlinkowski

    (@tlinkowski)


    Hi,

    Thanks for a great plugin!

    Would you consider supporting the “reading time” of figures (images)?

    This is how I patched your plugin to support this (only <figure> tag, as in Gutenberg Editor).

    Current:

    
    	// get raw content with no html tags
    	$word_count = strip_tags(get_post_field( 'post_content', $post->ID ));
    

    Patched:

    
    	$post_content = get_post_field('post_content', $post->ID );
    	// get raw content with no html tags
    	$word_count = strip_tags($post_content);
    

    Current:

    
    	$time_length = round($word_count / $wpm);
    

    Patched:

    
    	$ppm = 4; // pictures per minute
    	$figure_count = substr_count($post_content, '<figure');
    	$time_length = round($word_count / $wpm + $figure_count / $ppm);
    

    If you like it, feel free to reuse it!

    Regards,
    Tomasz Linkowski

    • This topic was modified 6 months, 4 weeks ago by  tlinkowski.
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Feature proposal: including figures (images) in reading time calculation’ is closed to new replies.