Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Contributor Nuanced Media

    (@nuanced-media)

    flojnel,

    So the excerpt length is set in /js/rich-reviews.js on line 16 it is the variable max_length. So setting this to a very high number, or simply commenting out lines 17- 37 of that js file would have the effect of simply displaying full review content. This limit is set bases on character count, and not word count, which is why you often get the break in the middle of words. It does however, expand and contract correctly (contracted:https://puu.sh/lreR7/a3f035a225.png, expanded: https://puu.sh/lreRR/973fc1c25d.png) which I think users understand, however I do also understand the desire for it to break between words. Adding a quick while loop just after opening of the if statement to simply extend the excerpt to the next white space will also solve your problem.

    while(jQuery(this).html().charAt(max_length) != ' ') {
         max_length += 1;
    }

    creating the resulting code block

    if(jQuery(this).html().length > max_length){
        while(jQuery(this).html().charAt(max_length) != ' ') {
             max_length += 1;
        }
        var short_content 	= jQuery(this).html().substr(0,max_length);
        var long_content	= jQuery(this).html().substr(max_length);
         jQuery(this).html(short_content+'<span class="ellipses">... </span><a href="#" class="read_more"><br />Read More</a>'+'<span class="more_text" style="display:none;">'+long_content+' <br /><a href="#" class="show_less" style="display:none;">Less</a></span>');
          jQuery(this).find('a.read_more').click(function(event){
               event.preventDefault();
               jQuery(this).hide();
               jQuery(this).parents('.rr_review_text').find('span.ellipses').hide();
               jQuery(this).parents('.rr_review_text').find('.more_text').show();
               jQuery(this).parents('.rr_review_text').find('a.show_less').show();
           });
           jQuery(this).find('a.show_less').click(function(event){
                event.preventDefault();
                jQuery(this).hide();
                jQuery(this).parents('.rr_review_text').find('.ellipses').show();
                jQuery(this).parents('.rr_review_text').find('.more_text').hide();
                jQuery(this).parents('.rr_review_text').find('a.read_more').show();
            });
    }

    This is probably the preferred solution. And I’ll be sure to make this adjustment in the next update, and possibly include an option for the excerpt length.

    Let me know if you have any further questions,
    Thanks,
    Charlie Maxwell
    [NM_Developer]

    franq77

    (@franq77)

    I would like an option in the configuration menu to set this to: a. no limit, b. limit on X words, c. limit on Y chars.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Words breaking before and after 'read more'’ is closed to new replies.