Fix PDF Embedder not Resized in Closed Accordions

Written by Dan Mossop

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, in the Divi Theme, when a PDF is hidden inside a closed 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>

Unlock the Full Potential of Shortcodes in Divi!

Empower your Divi site with the Divi Shortcode Enabler. This plugin allows shortcodes to run effortlessly in various Divi module fields, enhancing functionality and customization across your site. Ideal for fixing display issues like adjusting PDF sizes in accordions.

About Dan Mossop

Dan is a Scottish-born web developer, now living in Brisbane with his wife and son. He has been sharing tips and helping users with Divi since 2014. He created Divi Booster, the first Divi plugin, and continues to develop it along with 20+ other Divi plugins. Dan has a PhD in Computer Science, a background in web security and likes a lot of stuff, 

0 Comments

Submit a Comment

Comments are manually moderated and approved at the time they are answered. A preview is shown while pending but may disappear if your are cookies cleared - don't worry though, the comment is still in the queue.

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

We may earn a commission when you visit links on our website.