WordPress.org

Forums

Contextual Related Posts
[resolved] Support for custom images folders (4 posts)

  1. TrishaM
    Member
    Posted 1 year ago #

    Hey Ajay,

    I love Contextual Related Posts, it's a great plugin, but I accidentally broke one site again when I updated because I forgot that I had to hack your plugin to accommodate that I use a different folder defined in my wp_config file for storing all images.

    That site still has an old Theme that needs to be updated but I won't get to it for a bit yet….it does use a custom field metakey to hold the image name (called Image, not post-image) and I've entered that in the plugin settings, but because the images are not in the usual media library or uploads, CRP doesn't know where to find them.

    SO in your plugin around line 798 I have to add the path to the image folder to the line for $new_pi, changing:

    $new_pi = $postimage;

    to

    $new_pi = 'http://myurl.com/images/'.$postimage;

    In your next version, can you just add a setting for absolute URLs to images folders for those of us who don't use the media library?

    Many thanks,
    Trisha

    https://wordpress.org/plugins/contextual-related-posts/

  2. Ajay
    Member
    Plugin Author

    Posted 1 year ago #

    Hi,

    You should be able to create a function in your themes functions.php exactly along the lines of crp_scale_thumbs to modify the image link.

    Something like this.

    function crp_diff_image_folder( $postimage, $thumb_width, $thumb_height, $thumb_timthumb, $thumb_timthumb_q, $post ) {
    
      return 'http://myurl.com/images/'.$postimage;
    }
    add_filter( 'crp_postimage', 'crp_diff_image_folder', 9, 6 );
  3. TrishaM
    Member
    Posted 1 year ago #

    Thanks Ajay - this worked great for me, sorry I forgot to mark it "resolved" before now.

    I still think this would be a great option to add in your plugin's settings next time you update it…..not everyone is comfortable with modifying their functions.php file.

    I do love this plugin though, in my opinion it is the best one for showing related posts. :-)

  4. Ajay
    Member
    Plugin Author

    Posted 1 year ago #

    Hi,

    It's something I thought about, but it is also one thing that is likely to be used very little by users. But, it throws in yet another options for people to break their head against.

    Additionally, the plugin pulls in images from multiple ways which further complicates things.

    Hence, the reason for sprinkling of filters to help out :)

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Contextual Related Posts
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic