Fix PDF Embedder not Resized in Closed Accordions

This post may contain referral links which may earn a commission for this site

The PDF Embedder plugin allows you to easily embed PDFs in your web pages. When the browser window is resized, PDF Embedder resizes PDFs to fit the new space available to them. However, when a PDF is hidden inside a closed Divi accordion module toggle, it isn't resized when the browser window is resized. Thus when the accordion toggle is opened, the PDF displays at the old, incorrect size.

This can be fixed by adding the following jQuery code to your site:

<script>
/* Fix PDF Embedder not resizing in closed accordions */
jQuery(function($){
	$('.et_pb_accordion .et_pb_toggle_title').on('click', function() {
		var $toggle = $(this).closest('.et_pb_toggle');
		if ($toggle.hasClass('et_pb_toggle_close')) {
			setTimeout(
				function() {
					$toggle.find('.pdfemb-viewer').pdfEmbedder();
				},
				100
			);
		}
	});
});
 </script>

Hundreds of new features for Divi
in one easy-to-use plugin

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *