• I’m creating a website for an art collection that needs to display multiple images for each artist. I’ve decided to do this with custom meta fields. I’ve created new meta fields for up to four images with caption and option to download more information. My issue is that I need to be able to crop the images to the exact size. I was successfully able to do this with the featured image, which I’m using on a separate collection page, but not on the artist page with uploaded image.

    Here is the code for the image on the single artist page:

    <div class="artist-single-image">
    	<img src="<?php echo get_post_meta($post->ID, 'dbt_image1', true); ?>"><br>
    	<?php echo get_post_meta($post->ID, 'dbt_image1_caption', true); ?><br>
    	<a href="<?php echo get_post_meta($post->ID, 'dbt_image1_download', true); ?>" target="_blank">Download Info</a>
    </div>

    I’ve also created a custom image size:
    add_image_size( 'single-artist', 250, 300, true );

    Here is the code used to create the custom meta field:

    $prefix = 'dbt_';
    $meta_box = array(
        'id' => 'my-meta-box',
        'title' => 'Custom meta box',
        'page' => 'artist',
        'context' => 'normal',
        'priority' => 'high',
        'fields' => array(
            array(
                'name' => 'Image1',
                'desc' => 'Enter URL of first image',
                'id' => $prefix . 'image1',
                'type' => 'text',
    			'size' => 'single-artist',
                'std' => ''
            ),
    		array(
                'name' => 'Image 1 Caption',
                'desc' => 'Enter caption for first image',
                'id' => $prefix . 'image1_caption',
                'type' => 'text',
                'std' => ''
            ),
    		array(
                'name' => 'Image 1 Download',
                'desc' => 'Enter URL for pdf download',
                'id' => $prefix . 'image1_download',
                'type' => 'text',
                'std' => ''
            )))

    I feel like this is a pretty simple fix, but just can’t find it. I also do NOT want to use a plugin. Thanks for your help and let me know if I need to clarify!

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Custom Meta Field Image Size’ is closed to new replies.