Skip Navigation

[Gelöst] Want to crop featured image in a Div background

This support ticket is created vor 2 Jahre, 10 Monate. There's a good chance that you are reading advice that it now obsolete.

Dies ist das technische Support-Forum für Toolset – eine Suite von Plugins zur Entwicklung von WordPress-Websites ohne PHP-Pogrammierung.

Jeder kann in diesem Forum lesen, aber nur Toolset-Kunden können darin Beiträge veröffentlichen. Der Toolset-Support arbeitet 6 Tage pro Woche, 19 Stunden pro Tag.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 6 Antworten, has 2 Stimmen.

Last updated by Christian Cox vor 2 Jahre, 10 Monate.

Assigned support staff: Christian Cox.

Author
Artikel
#1721787

Hi there,

in a Div, which is a wrapper of a slider post I simply want to use the featured image as a background image covering the whole Div. How can I use a bigger sized image but crop and center center it?

This here is not working:

########
<div class="wrapper" style="background-image:url([wpv-post-featured-image size="full" width="100%" height="420px" crop='true' crop_horizontal="center"]">
########

What is the right spelling for it?

Jörg

#1722099

Hello, I think you should use the CSS background-position property to move the image around in the div, use background-size to adjust the height and width of the background image, and use the wpv-post-featured-image shortcode to provide the full size image URL. The background-position "center center" should place it in the middle. The background-size "cover" will ensure the entire area is covered by the image. I would not try to crop or position the image by adjusting the configurations in the wpv-post-featured-image shortcode. To troubleshoot the problem, remove the wpv-post-featured-image shortcode and replace it with the URL of the full-size version of one of the featured images. This will help you test things out.

<div class="wrapper" style="background:url(<em><u>hidden link</u></em>); background-position: center center; background-size: cover;">
  your slider div content
</div>

Replace the URL above with the actual featured image URL (you can find that in the Media Library), and put your slider inside the div content. Then you can adjust the CSS for the background as needed. Once you have this working, replace the URL with the wpv-post-featured-image shortcode.

https://www.w3schools.com/cssref/css3_pr_background-size.asp
https://css-tricks.com/almanac/properties/b/background-position/

If you show me on the front-end of your site I can take a closer look.

#1722565

Hi Christian,...

thx for your soon reply

Maybe it was not clear,... I need the featured post mage in the background. It is in the Post-Slider-View - Slide

I can´t use the static url here, it is in a loop.

unfortunately this here (using the [wpv-post-featured-image]does not work:

You can have a look on the test page the red bordered frame on: hidden link

#####
<div class="wrapper" style="background:url([wpv-post-featured-image]); background-position: center center; background-size: cover;">
your slider div content
</div>
#######

thx
Jörg

#1723109

I wanted to use a static URL for testing, but it's not a problem. I can show you how to fix the shortcode. You need output="url" like in this example:

<div class="wrapper" style="background:url([wpv-post-featured-image output='url']); background-position: center center; background-size: cover;">

Otherwise, the shortcode will output a full image tag. You don't want that, you just want the image URL.
https://toolset.com/documentation/programmer-reference/views/views-shortcodes/#wpv-post-featured-image

#1723609

Hi Christian,

again thx for your soon reply.

I actually have 2 smaller problems on your solution:

1. I don´t understand the "&#039" used two times

and

2. If you look at my staging page (hidden link) the image is not the right size and it is not in full size, a cropping problem?

may I ask you for help again to fix it?

Jörg

#1723703

Hi Christian,

With your help and with a bit of trial and error I fixed it.

It needed an additional - size="large" -

Thx for your help

Jörg

#1725119

Ok thank you for the update, I will close here.

Das Forum „Toolset Professioneller Support“ ist für neue Themen und Antworten geschlossen.