2

I want to limit images in Woocommerce product long description. I have found the following code from this answer thread, but it is only applying for to limit text. How can I limit images in the description? is there any way to do it?

Reduce product long description in Woocommerce

// Set the limit of words
$limit = 14;

if (str_word_count($content, 0) > $limit) {
    $arr = str_word_count($content, 2);
    $pos = array_keys($arr);
    $text = '<p>' . substr($content, 0, $pos[$limit]) . '...</p>';
    $content = force_balance_tags($text); // needded
}
return $content;

}

0 Answers0