Viewing 15 replies - 1 through 15 (of 31 total)
  • Plugin Author Ajay

    (@ajay)

    Will need more information – website URL and which posts are you referring to in particular. Lastly, what are you expecting to see and what you’re seeing

    Thread Starter darylaurito

    (@darylaurito)

    I am getting custom post from custom field. My image return in image array so it return id when I inspect source.

    Plugin Author Ajay

    (@ajay)

    A custom post shouldn’t be an issue as the plugin supports that. But, i’m not clear what do you mean custom field and the image array?

    Please see my previous post as to what I would need to see

    Thread Starter darylaurito

    (@darylaurito)

    View post on imgur.com

    I would like to get the first image from my post however now it is getting the featured image of my post. Is there a filter or setting to get the first image from my post? Please advise Ajay. Thanks

    Plugin Author Ajay

    (@ajay)

    Thanks – I understand now. The featured image is the priority vs the first image. If the plugin can’t find the featured image, then it pulls the first image.

    Please see the code here: https://github.com/WebberZone/contextual-related-posts/blob/v3.0.3/includes/media.php#L118

    The filter holding the thumbnail URL is: crp_thumb_url

    Thread Starter darylaurito

    (@darylaurito)

    Hi Ajay, thanks for the reply. Saw the code, does this mean I can set priority to displaying my custom image by specifying the meta name in that function and if my custom image is null then i will get the first image from post content? Please advise thank you.

    Thread Starter darylaurito

    (@darylaurito)

    Also is the one you pointed out I can apply filter to it through my functions.php or i have to change the media.php file?

    Thread Starter darylaurito

    (@darylaurito)

    I tried commenting out other options and only include get meta field name and getting first image from post. But it seems I keep getting image ID instead of URL. Please advise

    Screenshots

    View post on imgur.com

    Plugin Author Ajay

    (@ajay)

    You are correct on the meta name. If you have a meta-field in the post that contains the direct URL of the image, then you can use that one. Alternatively, you can find this in the meta box at the bottom of the edit post screen – but with the original name (not the one in your screenshot).

    Also alternatively, you can put a function in your functions.php to pull an image of your choice.

    This should then add_filter( 'crp_thumb_url', 'functionname' );

    You can borrow lines 132-145 which pulls out the image from the post content and then tries to get the correct size thumbnail from there
    https://github.com/WebberZone/contextual-related-posts/blob/v3.0.3/includes/media.php#L132-L145

    Thread Starter darylaurito

    (@darylaurito)

    Hi Ajay thanks for the reply.

    Here is the meta box in my edit post screen. Do I put that in the meta field settings.

    Screenshot:

    View post on imgur.com

    Thanks!

    Plugin Author Ajay

    (@ajay)

    You need the full URL of the thumbnail so something like https://sitename.com/image.png

    • This reply was modified 3 years, 10 months ago by Ajay.
    Thread Starter darylaurito

    (@darylaurito)

    Hi Ajay, so I can’t use the meta field name “article_header_image” ?

    Thread Starter darylaurito

    (@darylaurito)

    Or I need to add in functions to parse the post meta array to image url?

    Plugin Author Ajay

    (@ajay)

    If article_header_image already contains the full URL of the image then you don’t need to do anything else as the plugin should pick this up. However, if it doesn’t then you’ll need to reset it back to the default setting which is post-image

    Thread Starter darylaurito

    (@darylaurito)

    Hi Ajay, is there an example of the apply filter function? can’t seems to get the function

Viewing 15 replies - 1 through 15 (of 31 total)
  • The topic ‘Retrieving first image’ is closed to new replies.