Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2008-12-10 04:06:22

masa
Member
From: Asturias, Spain
Registered: 2005-11-25
Posts: 1,091

Rounding image corners dynamically

I have a site that would require images posted in articles to display with rounded corners, without the need for the end-users to do that in an image editor prior to uploading.

I tried jQuery Corners but that just adds top- and bottom padding to the image using the radius defined for the corners.

However, I want the image to appear masked as in the sample at the bottom (disregard the drop-shadow).

How would I go about this so that the container also fits the image’s dimensions?

Last edited by masa (2008-12-10 04:12:30)

Offline

#2 2008-12-10 05:07:52

jm
Plugin Author
From: Missoula, MT
Registered: 2005-11-27
Posts: 1,746
Website

Re: Rounding image corners dynamically

What about swfIR?

Offline

#3 2008-12-10 11:33:28

masa
Member
From: Asturias, Spain
Registered: 2005-11-25
Posts: 1,091

Re: Rounding image corners dynamically

Thanks jm,
that’s certainly what I had in mind regarding the end result.
What puts me off though is the initial flash of the unstyled image and the fairly long delay before it is rendered properly.

I was hoping to get away with some css- and js trickery.

Offline

#4 2008-12-10 13:39:10

kemie
Plugin Author
From: mexico<-->sweden
Registered: 2004-05-20
Posts: 495
Website

Re: Rounding image corners dynamically

for a recent project, i tried all jquery-based image conrners out there. settled finally for:
jquery roundedcorners the only one i found that works with paddings, borders, and background images

Last edited by kemie (2008-12-10 13:39:55)


~~~~~~~~~~~~~| monolinea.com | pixilate.com | istockphoto.com/kemie |~~~~~~~~~~~~~

Offline

#5 2008-12-14 10:21:36

masa
Member
From: Asturias, Spain
Registered: 2005-11-25
Posts: 1,091

Re: Rounding image corners dynamically

kemie,

thanks, that one does the trick.
I was hoping I could give all images in the main #content div the rounded-corners treatment with a catch-all rule like this:

$(”#content img”).corner(”15px”);

But it’s not possible to target the img element directly. I contacted the author and he’s considering making this a feature in a future release :-)

As a workaround for the moment I’ll wrap each image in a floated div of the same dimensions.

Offline

#6 2008-12-15 09:10:47

kemie
Plugin Author
From: mexico<-->sweden
Registered: 2004-05-20
Posts: 495
Website

Re: Rounding image corners dynamically

ah, the one thing i did not try was rounding images :D


~~~~~~~~~~~~~| monolinea.com | pixilate.com | istockphoto.com/kemie |~~~~~~~~~~~~~

Offline

#7 2009-02-19 14:51:51

masa
Member
From: Asturias, Spain
Registered: 2005-11-25
Posts: 1,091

Re: Rounding image corners dynamically

Just as a follow-up this is what I’m using now to pull a single article image into a container that fits snugly and has rounded corners.

article form:

<h2><txp:title /></h2>
<txp:upm_if_article_image />
<txp:upm_article_image form="upm_article_image" />
</txp:upm_if_article_image />
<txp:body />

form “upm_article_image”:

<div class="rounded" style="width: <txp:upm_img_full_width />px; height: <txp:upm_img_full_height />px;">
<img src="<txp:upm_img_full_url />" width="<txp:upm_img_full_width />" height="<txp:upm_img_full_height />" alt="<txp:upm_img_alt />" title="<txp:upm_img_caption />" />
</div>

Seems to work perfectly except for in Opera and IE8 rc.

I don’t suppose there’s any way to hide html code from Opera?

Offline

#8 2009-02-19 16:07:11

mrdale
Member
From: Walla Walla
Registered: 2004-11-19
Posts: 2,215
Website

Re: Rounding image corners dynamically

So you just have two corners right? why not just hang one corner mask gif on the containing element (for bottom right) and one on the first contained element (top left).

I did that here… which seems like a lifetime ago.

Last edited by mrdale (2009-02-19 16:07:50)

Offline

#9 2009-02-19 16:21:10

masa
Member
From: Asturias, Spain
Registered: 2005-11-25
Posts: 1,091

Re: Rounding image corners dynamically

mrdale wrote:

So you just have two corners right?

Well, this time it’s actually all four. I’ve used the method you describe, but the new one is pretty simple: just one <div> and the plain <img> inside.

Offline

#10 2009-02-19 16:32:40

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: Rounding image corners dynamically

masa wrote:

I don’t suppose there’s any way to hide html code from Opera?

This will add a class opera to the body, so that you can serve it a different style:

<script type="text/javascript">
$(document).ready(function(){
if ($.browser.opera) {
$("body").addClass("opera");
}
});
</script>

Offline

#11 2009-02-19 22:19:26

masa
Member
From: Asturias, Spain
Registered: 2005-11-25
Posts: 1,091

Re: Rounding image corners dynamically

Thanks Els,

the thing is I need to output a block of <script> tags in the <head> for any browser but Opera and I’ve found a php browser detection script that seems to do the trick.
Nevertheless I’ve saved your suggestion for other uses :-)

Offline

#12 2009-02-19 22:47:23

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: Rounding image corners dynamically

masa wrote:

a block of <script> tags in the <head> for any browser but Opera

Ah, I see, but in that case you could change it to if (!$.browser.opera) and add your jQuery code after that I think.

Offline

Board footer

Powered by FluxBB