Recent Topics

allowing relative URL of image in post

Started by on Mar 26, 2005 – Contents updated: Mar 26, 2005

Mar 26, 2005 10:24    

The post can only accept absolute URLof image (ex. <img src ="http://xxx.xxx.xxx/blog/media/img.jpg">)

I wish that the post can accept relative URL of image, (ex. <img src="../../media/img.jpg">)
but I don't know that how to edit conf/_formatting.php file~

It is too complexity to understand~ :oops:

Mar 26, 2005 15:03

Marty,

I know WHERE in the formatting file a modification needs to be made, but I've experienced nothing but frustration trying to get past a similar problem. (See my post [url=http://forums.b2evolution.net/viewtopic.php?t=3393]here[/url], which I just bumped again today).

The [url=http://doc.b2evolution.net/0.9.1/evocore/SafeHtmlChecker.html#var$allowed_uri_scheme]technical doc[/url] isn't yielding anything meaningful either.

I suspect that a core file hack and NOT just a simple edit of the _formatting.php file is required to achieve our objectives, but I haven't had any assistance in this matter (a sure sign it is an obtuse fix).

However ... in playing with your problem this morning, I have come up with a work-a-round that you may find suitable.

Simply put the picture in the background of an image tag, using inline-CSS formatting, as such:

<img src="" style="background:url(../../../_img/blog/yourPhoto.jpg); height:XXXpx; width:XXXpx;" title= " your title  " alt= "your image alt description" />

By not specifying a 'SRC', you're gonna get the red, boxed "X" placeholder, indicating that an image couldn't be loaded ... BUT you could get around this by (a) making a 1px by 1px image or (b) making a transparent GIF. Either way, you'd need a fully-qualified path to the file.

<img src="http://mysite.com/blank.gif" style="background:url(../../../_img/blog/yourPic.jpg); height:XXXpx; width:XXXpx;" title= " your title " alt= " don't forget the alt text " />

BUT ... if you can get around THAT ... then you could use your relative paths without having to change a thing in your _formatting.php file.

-Sneeky Scott ;)

EDIT: On a second thought, I believe that you will lose the 'title' attribute with only a background image. To overcome this, you would need to have a transparent gif that's sized identical to the relative image, which would require a Xparent GIF for each then :( ... unless you don't use the title attribute :)

EDIT**(2): On third thought, maybe not, since the H/W are defined in the inline CSS. Perhaps the transparent GIF would be STRETCHED to fit the larger container? Hmmm. Either way, I'm gonna go eat some breakfast. :)

Mar 28, 2005 05:15

stk, thank for your reply! :D
I will try it~


Form is loading...

Open Source CMS – This forum is powered by b2evolution CMS, a complete engine for your website.