Skip to content

Editing theme images

scribu edited this page May 2, 2012 · 6 revisions

Say you have a theme template file with an image in it. It's really difficult to allow users to change that image without editing the file.

Fortunately, Front-end Editor offers a solution. Replace something like this:

<img src="<?php bloginfo('template_url'); ?>/images/header_1.jpg" width="970" height="140" alt="<?php bloginfo('name'); ?> header image 1" title="<?php bloginfo('name'); ?> header image 1" />

with this:

<?php editable_image( 
	'header-1',
	get_bloginfo('template_url') . '/images/header_1.jpg', 
	array(
		'width' => 970,
		'height' => 140, 
		'alt' => get_bloginfo('name')
	)
); ?>

Now, users will be able to click the Edit button and replace that image with another one from the media library.

Clone this wiki locally