Skip Navigation

[Résolu] Background Image Size Override

This support ticket is created Il y a 1 année et 5 mois. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Aucun de nos assistants n'est disponible aujourd'hui sur le forum Jeu d'outils. Veuillez créer un ticket, et nous nous le traiterons dès notre prochaine connexion. Merci de votre compréhension.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

Ce sujet contient 4 réponses, a 2 voix.

Dernière mise à jour par Line49 Design Il y a 1 année et 5 mois.

Assisté par: Luo Yang.

Auteur
Publications
#2615183

Tell us what you are trying to do?
We use Toolset to manage dynamic content such as grids of real estate listings. Like others, we have noticed that the dynamic background images appearing in these grids cause a performance issue, since they reference the default original image at full size.

We see at the various links provided that this has been a feature request for years but is not available yet.
https://toolset.com/forums/topic/background-image-size
https://toolset.com/forums/topic/background-images
https://toolset.com/forums/topic/serving-custom-size-background-images-to-reduce-page-load-times-and-size-in-grid
https://toolset.com/forums/topic/choosing-image-size-with-toolset-image-block

However, we don't need you to rewrite your software to solve this item.

We simply need a function we can, say, paste into functions.php, which will globally override the default Full size with any other given size, such as Medium.

Can you please provide us with such a function?

What is the link to your site?
lien caché

#2615231

Hello,

You can setup the Background Image with HTML codes manually, for example:

<div class="wp-block-toolset-blocks-container tb-container" style="background: url([wpv-post-featured-image size="medium" output="url"]) center center no-repeat;background-size: 300px 156px;">
<p>test </p>
</div>

See below sandbox website:
Login URL: lien caché
Frontend result:
lien caché

More helps:
lien caché

#2615919
Screenshot 2023-06-14 103315.png

Thank you for your quick response!

We are using blocks, I will attach a screen capture, to show the structure of the blocks, the container in question is highlighted. I'm not sure how to use the provided shortcode.
Also we have multiple views very similar with the attached example.
So best for us would be to use a function, which will globally override the default Full size with any other given size, such as Medium.

Thanks again for your help,
Ligia

#2616017

Unfortunately, there isn't such kind of built-in feature or function within Toolset Blocks plugin, you just need to add two custom HTML blocks, and display the HTML div tag, for example:

<div class="wp-block-toolset-blocks-container tb-container" style="background: url([wpv-post-featured-image size="medium" output="url"]) center center no-repeat;background-size: 300px 156px; width:300px; height:156px;">
</div>

And wrap other contents into above custom HTML blocks, see the sandbox website:
lien caché

Frontend result:
lien caché

#2617759

My issue is resolved now. Thank you!