functions - (Divi): How to make Wordpress load images of specific size for Blurb modules on given page with a funciton?

I have 28 pictures uploaded to media library, each around 3mb. Wordpress has already created resized copies of those: th

I have 28 pictures uploaded to media library, each around 3mb. Wordpress has already created resized copies of those: thumbnails, medium and large. The pictures are used as Divi's Blurb module images on a given page. They are all being loaded full sized (even if I choose Large when picking an image for module). 28*3mb is a lot.

What I want, is to write a neaty function in functions.php (child theme), that will rewrite all requests for image urls ( e.g. IMG_4321.jpg ), only for this specific page, and only for blurb modules, to urls to those large sized images created by wp ( IMG_4321-683x1024.jpg ). Maybe there's a funciton used by themes for accessing images that I can hook into?

I imagine it would start as:

if( is_page('menu') ) {

}  

But that's as far as I can go.

I have 28 pictures uploaded to media library, each around 3mb. Wordpress has already created resized copies of those: thumbnails, medium and large. The pictures are used as Divi's Blurb module images on a given page. They are all being loaded full sized (even if I choose Large when picking an image for module). 28*3mb is a lot.

What I want, is to write a neaty function in functions.php (child theme), that will rewrite all requests for image urls ( e.g. IMG_4321.jpg ), only for this specific page, and only for blurb modules, to urls to those large sized images created by wp ( IMG_4321-683x1024.jpg ). Maybe there's a funciton used by themes for accessing images that I can hook into?

I imagine it would start as:

if( is_page('menu') ) {

}  

But that's as far as I can go.

Share Improve this question asked Apr 25, 2019 at 23:45 Danyl FilatovDanyl Filatov 1413 bronze badges 1
  • if the image weight is your problem (~3MB for one), you should use optimized/compressed images. either you can use plugin for that or you can manually compress images and upload – Vishwa Commented Apr 26, 2019 at 6:07
Add a comment  | 

1 Answer 1

Reset to default 0

Elegant Themes (Divi) recommend a maximum width of 550px for blurb images (https://www.elegantthemes/blog/divi-resources/the-ultimate-guide-to-using-images-within-divi). So you should be resizing your images according to those guidelines for the images that you know will be used in your blurbs. This will ensure that your images don't cause WordPress too much memory effort to resize them on the fly, and should also mean your images will have a smaller filesize too.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745550135a4632537.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信