Forums

remove all images from database (5 posts)

  1. CFCnet
    Member
    Posted 3 years ago #

    Hi
    Guys I need to remove all images from the database.

    This is because i want to show a default one if there are none specified.

    I'm changing theme so I need to use different size images thus negating the need for the current one.

    http://www.cfcnet.co.uk
    to
    http://server34.ipslink.com/~clubcfcn/cfcnet/

  2. MichaelH
    Volunteer
    Posted 3 years ago #

    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".

  3. CFCnet
    Member
    Posted 3 years ago #

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

  4. ryans149
    Member
    Posted 2 years ago #

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

  5. doc4
    Member
    Posted 2 years ago #

    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 } ?>

Topic Closed

This topic has been closed to new replies.

About this Topic