[wp-hackers] Image URL changes

Andrew Nacin wp at andrewnacin.com
Wed Mar 3 20:43:13 UTC 2010


One thing I would recommend is to no longer use
get_option('siteurl') or get_option('home'). For siteurl, use site_url(),
and for home, use home_url(). These functions handle SSL, as does
admin_url().

They're also cleaner to write, and they accept a parameter which then
appends a path for you.

get_bloginfo('url') and get_bloginfo('wpurl') are now aliases for home_url()
and site_url(), perspectively.

Adding to this, there has been some talk of an image shortcode. It
originated as a possible solution to implementing trash for media, but it
hasn't gained much traction yet.

On Wed, Mar 3, 2010 at 3:29 PM, Otto <otto at ottodestruct.com> wrote:

> On Wed, Mar 3, 2010 at 12:58 PM, Matthew Barr <mbarr at interactiveone.com>
> wrote:
> > In implementation, it might be a short code, with the file path -
> >
> > [wpimg  files/2010/02/image.jpg]
> >
> > Or anything else that y'all think is a good way to implement it.
>
> I like it, but it's not generic enough for me.
>
> How about if you did something like this in a post?
> <img src="[homeurl]/wp-content/uploads/whatever.jpg" />
>
> [homeurl] is simply replaced with the home url. The shortcode handler
> for that is like two lines of code:
> function homeurl_shortcode() { return get_option('siteurl'); }
> add_shortcode('homeurl', 'homeurl_shortcode');
>
> Or, if you want it more specific, have [homeurl], [contenturl],
> [adminurl], etc... Whatever makes sense.
>
> -Otto


More information about the wp-hackers mailing list