• Resolved tiborbogun

    (@tiborbogun)


    Dear Brianna

    It seems that your Plugin does exaktly what I am looking for. Eventually. May I ask you if there is any way to use it for random background-images?

    This is my Hero HTML

    <div class="header_random-image">
    	<div id="hero"></div>
    </div>

    I would like to insert a random background-image using this CSS

    #hero {
      background-image: url( RANDOM IMAGE INSIDE HERE );
      background-size: cover;
      background-position: 50% 30%;
      height:70vh;
      width: 100%;
      margin-top: -65px;
    }

    To use it as a background-image I need to output just the image-URL and I need to place it on to the right place in this CSS-rule.

    Further I’d like to extrakt at least one image meta-field (the caption for example) to display a unique URL beside my hero image. have a look here: https://www.dropbox.com/s/6dbu7g3dajp7q1b/RRHI.jpg?dl=0

    As you probably see I am not a developer but after two days of investigation I am quite desperate. Is a user-friendly and responsive random-hero-image rocket science?

    Best from Berlin
    Tibor

Viewing 1 replies (of 1 total)
  • Plugin Author Brianna Deleasa

    (@bdeleasa)

    Hi Tibor! I’m very happy to hear you’ve found the plugin useful! ??

    I’m not sure exactly which set of random images you need to retrieve, but there are some template tags in the includes/template-tags.php file that allow you to retrieve a random thumbnail anywhere in a plugin/theme:

    1. wprpt_get_random_image() – Retrieves 1 random image out of ALL images uploaded through ALL tabs of the admin area.
    2. wprpt_get_global_images() – Retrieves 1 random image out of the images uploaded through the Global Options tab.
    3. wprpt_get_post_type_images( $post_type ) – Retrieves 1 random image out of the images uploaded through the Post Type Options tab, based on the specific post type passed in.
    4. wprpt_get_taxonomy_term_images( $taxonomy, $term_obj ) – Retrieves 1 random image out of the images uploaded through the Taxonomy Options tab, based on the taxonomy slug and term ID passed in.

    These functions return a PHP array of information about the random image, including the attachment ID. You’ll be able to grab whatever WordPress generated image size and metadata you need using the WordPress wp_get_attachment_* template functions.

    I hope this helps! ??

Viewing 1 replies (of 1 total)
  • The topic ‘Random Background Image?’ is closed to new replies.