WordPress.org

Forums

WP Tiles
[resolved] Need to grab image url from custom field (5 posts)

  1. djezer
    Member
    Posted 1 year ago #

    Hello, first off, great plugin! I've started playing with it yesterday and am in the process of integrating it to a site. The problem lies in the fact that it is using the Dynamic Content Gallery presently and when they add an image to a post, they copy the image url and post it in a custom field along with the DCG box. Perhaps this is why the WP Tiles plugin doesn't see the image for each post. Is there a way to tell the plugin to fetch the url for the image in a custom field?

    Thanks.

    http://wordpress.org/plugins/wp-tiles/

  2. djezer
    Member
    Posted 1 year ago #

    Here's the link to there current plugin:
    http://wordpress.org/plugins/dynamic-content-gallery-plugin/installation/

    And I just wanted to clarify the way images are handled in the current process. Users upload the image to the wordpress and copy the url and pasted in two separate boxes when creating a new post. The first post is a Custom Field type 'Image' and the second is the box for the DCG plugin.

    With this setup it seems like Tiles doesn't know to get the image from the custom field. Is there a fix for this?

  3. djezer
    Member
    Posted 1 year ago #

    I'm reading about custom fields here:
    http://codex.wordpress.org/Using_Custom_Fields

    And it looks like I'm going to fetch the image data using something like this:
    get_post_meta($post_id, ‘image', true);

    I'm not sure how to integrate it in the Tiles plugin though. Any help would be appreciated.

    Thanks.

  4. Mike Martel
    Member
    Plugin Author

    Posted 1 year ago #

    Hi there! There's a filter in WP Tiles just for this: pre_wp_tiles_image. The second argument is the post. If you return the src for the image through this filter, everything should work.

    So add something like this to you functions.php:

    add_filter( 'pre_wp_tiles_image', 'grab_dcg_image_for_wp_tiles', 10, 2 );
    function grab_dcg_image_for_wp_tiles( $src, $post  ) {
        if ( $img = get_post_meta($post->ID, 'image', true) )
             $src = $img;
    
        return $src;
    }

    Good luck!
    Mike

  5. djezer
    Member
    Posted 1 year ago #

    Thanks Mike! All I had to add was a concatenation of the images' subfolder and it worked like a charm!

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • WP Tiles
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic