Learn in this tutorial how to change the image size of Easy Digital Downloads (EDD) products using code.
If you are using Easy Digital Downloads you may have noticed that product images sometimes look a bit pixelated, especially if you use custom styles.
This is because, by default, EDD uses the thumbnail size which is 150 x 150 pixels (px) images. So if you want to display the products, for example, in a grid of 250px each column, you should change the default size.
Is this your case? Here’s how to do it:
Snippet to change the image size of Easy Digital Downloads downloads
First of all, create a folder called edd_templates in the root of your theme. Then create inside it a file called shortcode-download.php with the following code.
To see this and another 1097 code snippets of this website, login or subscribe here.
In this case, what you get is to display the WordPress medium
size which by default is 300 x 300 pixels.
But you can also use other sizes of plugins or themes, even add a default image when the product does not have one.
To do this, you can use a code like the following:
To see this and another 1097 code snippets of this website, login or subscribe here.
In this case, you tell it to use the gb-block-post-grid-landscape
size if Genesis Blocks is active, and if not, to use the medium
size.
In addition, you indicate that if the product does not have an image, it should load one. In the example it will load the placeholder.jpg image that is in the /images/ folder inside the theme, but you can adjust it to your liking.
Conclusions
Do you want to customize the image size that Easy Digital Downloads uses for its products? Now you know how to do it easily using code.
If you have any question, please leave it in the comments. And if you want to give me a suggestion for future snippets, please send it through the contact form.
Benefits of being a subscriber. 🙂