0

I've been researching how to display thumbnails with rounded images, but every solution ends up running out of gas.

One trick I tried was wrapping the thumbnail in a division with the same size and shape, showing the image, but with CSS of opacity:0 so that the actual image doesn't show. What shows is the background image for the division, and it's this, also that is styled using:

border-radius: 15px;

(plus other browser related hacks)

To do this on WordPress, I'm going to have to use inline styles, it seems, to give the same div the right background image using

the_post-thumbnail()

Seems to lead to nowhere because I don't see a way to pull just the image url in a way that I can call within

<div style="   ";

Any ideas?

I'm trying to avoid Javascript, but if that's the only way...

Here's a link to the method I mentioned

1

You can get the thumbnail URL with wp_get_attachment_image_src and get_post_thumbnail_id:

$src = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'thumbnail' );
echo $src[0];

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.