[wp-hackers] absolute URLs in plug-ins and custom types

Casey Bisson casey.bisson at gmail.com
Tue Jul 3 03:11:37 UTC 2012

Have you considered leveraging WP's native image/attachments and simply store the ID of the attachment? From there it's very easy to generate a URL on the fly with wp_get_attachment_url( $id ) . Of course you can then automatically get different sizes as well.

Casey Bisson

On Jul 2, 2012, at 3:13 PM, Shasta Willson wrote:

> A number of the plug-ins I use, such as sliders, involve inputting an
> absolute URL for the image.  This is a problem at deployment (or any
> other move) obviously, but I'm not sure I've seen it done any other
> way.
> I'm building a custom type that includes two image uploads using the
> built-in media box.  I'd really like it to store a relative URL rather
> than an absolute one so I've considered using regex to just strip off
> everything to "/uploads".  Is there a downside to doing this?  Is
> there a better way to accomplish the goal?  Am I missing some reason
> everyone seems to store the absolute link?
> Thanks,
> Shasta
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers

More information about the wp-hackers mailing list