Viewing 4 replies - 1 through 4 (of 4 total)
  • Images themselves are not kept in the database, they are usually in a sub-directory such as wp-content/uploads.

    Now the wp_posts table contains references to images and those records have a post_type of “attachment”.

    Thread Starter cfcnet

    (@cfcnet)

    can a default image be shown if an image is not found?

    @michaelh
    I also want to know the same. Is there any entry in the database for images?? Except that you have mentioned..

    CFCnet,

    What you need is a php if statement to determine if the image exists. Try something like this to get started. This assumes that you are looking for an image in a custom field and the determines if custom field is empty.

    <?php if( get_post_meta($post->ID, 'customFieldName', true) ) { ?>
      <img src="<?php bloginfo('url'); ?>/wp-content/uploads/<?php echo get_post_meta($post->ID, 'customFieldName', $single=true) ?>">
    <?php } else { ?>
     <img src="path/to/default/image.jpg">
    <?php } ?>
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘remove all images from database’ is closed to new replies.