Getting the url of a featured image
-
I have set up featured images for my theme.
After the user has incorporated a featured image into his post, I’m running a ‘post-updated’ hook to see what the path of the featured image is:
add_action('post_updated','magico_after_saved'); function magico_after_saved($post_id) { $img= wp_get_attachment_image_src(get_post_thumbnail_id( $post_id )); magico_resize_image($img); }
Some files return the path to the original image, ie: https://127.0.0.1/divo/wp-content/uploads/2014/05/IPC.1.bmp
Others return the path to the thumbnail:https://127.0.0.1/divo/wp-content/uploads/2014/05/IPD.5-150×150.jpg
Currently I’m manipulating the path with strrchr() and substr() to extract the ‘-150×150’ string if it exists, but there must be a way of consistently retrieving the original file name rather than the thumbnail.
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Getting the url of a featured image’ is closed to new replies.