Nathan
Nathan

Reputation: 1762

images in WordPress page templates

Is there a good way to put images into a theme template so they can be be easily exchanged in WordPress? I've been trying to use wp_get_attachment_image_src( $id, $size ) but then I would need to somehow maintain the same id from old picture to new picture.

Additionally, wp_get_attachment_image_src( $id, $size ) is picking up auto-cropped thumbnail versions of my image rather than the original. If you can tell me why this is happening, then bonus to you!

Upvotes: 0

Views: 2123

Answers (1)

emersonthis
emersonthis

Reputation: 33368

You should create an /images folder within the theme's main folder and then reference the images from within your template file as follows:

//inside the template-file.php
<img src="<?php bloginfo('template_url'); ?>/images/your_image.jpg " />

The structure of your theme files should be something like this:

/your_theme_folder
    /images
        your_image.jpg
    template-file.php

Upvotes: 1

Related Questions