In order to make this work it needs to get the image URL, but the like box doesn’t display the image URL
The JS code:
image: '<img class="esgbox-image" src="{href}" alt="" />'
How can I get it to display: www.website.com/image.jpg
WP codes like: get_post_thumbnail_id()
only work if the URL is displayed in the browser window
<?php
$thumb_id = get_post_thumbnail_id();
$thumb_url = wp_get_attachment_image_src($thumb_id,'thumb', true);
?>
How can I make it work with this plugin?
https://www.ads-software.com/plugins/default-post-thumbnail-image/
]]>I’m using the following code to get the attached images from a post, only excluding the featured image.
<?php $thumb_ID = get_post_thumbnail_id( $post->ID ); if ( $images = get_children(array( 'post_parent' => get_the_ID(), 'post_type' => 'attachment', 'post_mime_type' => 'image', 'exclude' => $thumb_ID, ))) : ?>
<?php foreach( $images as $image ) : ?>
<div class="col-sm-4 col-xs-6">
<a class="fancybox-asset" href="<?php echo wp_get_attachment_url($image->ID, 'thumbnail-latest'); ?>" alt="Attached Image Title should be here" title="Attached Image Title should be here"></a>
</div>
<?php endforeach; ?>
<?php else: // No images ?>
<?php endif; ?>
What can I do to make it display the image title? (not the post title!)
]]>I have this:
$slider_image_id = get_post_meta($product->ID, 'Slider Image', true);
$post_image = wp_get_attachment_url($slider_image_id);
which loads the page’s specified image that is put in a ‘custom field’ box.
I was hoping I could put something like this:
$slider_image_id = get_post_thumbnail_id( $post_id );
$post_image = wp_get_attachment_image_src( $attachment_id );
But of course I’m not an expert… it is more complicated as the images are from ‘child’ pages.
You can see the code working here:
https://www.vendome.com.au/products/faberge-jewellery/
But I am having issues with the images loading in all IE.. sometimes/mostly they do not load.
I am hoping that calling them in cleanly might help, can anyone help?
Chrissy
]]>Fatal error: Call to undefined function get_post_thumbnail_id() in E:\xampp\htdocs\myproject\wp-content\plugins\facebook\fb-social-publisher.php on line 251
https://www.ads-software.com/extend/plugins/facebook/
]]>For some reason it just occurred to me (a-doy) to look at my server logs – turns out my ISP has been suppressing PHP errors. The error I’m getting is this:
PHP Fatal error: Call to undefined function get_post_thumbnail_id() in REDACTED/wp-admin/includes/media.php on line 1292, referer: https://REDACTED/wp-admin/media-upload.php?post_id=877&type=image&
Now this is baffling – I did a completely fresh install of WordPress to try and solve this problem, and yet I’m still getting an “undefined function” error. Why is this happening, and how can I fix it?
Any help is greatly appreciated. Thank you!
]]>It would be useful if has_post_thumbnail() had a similar hook. Right now if I want to use the filter to add a default image (say one based on the date of post, or category, or user) when the post itself does not have one there is no way of telling has_post_thumbnail() to indicate that there is actually going to be an image.
Similarly the get_post_thumbnail_id() could use a filter as well. There are two main reasons for this. Some themes make use of it to directly craft there own html and the ability to hook a plugin at this level would be useful to work with them. Secondly if I’m changing the ID of the image used for the thumbnail via the post_thumbnail_html filter then it would be useful to change the return value here to be in sync.
In short, can we get filters on:
I can return the ID using:
get_post_thumbnail_id($post_id);
but I want to return the name of the image so I can replace a part of it and then use that to call a different, yet similar, image.
Could be I’m using a clumsy-thumbed method to achieve what I want but *blush* it’s the only way I know how.
]]>