-
Notifications
You must be signed in to change notification settings - Fork 62
get thumbnail title and description #103
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -372,6 +372,32 @@ public static function get_post_thumbnail_url($post_type, $id, $post_id = 0, $si | |
|
|
||
| return $url; | ||
| } | ||
|
|
||
| /** | ||
| * | ||
| * @param string $post_type The post type. | ||
| * @param string $id The id used to register the thumbnail. | ||
| * @return thumbnail title. | ||
| */ | ||
| public static function get_post_thumbnail_title($post_type, $id) { | ||
| $post_id = get_the_ID(); | ||
| $post_thumbnail_id = self::get_post_thumbnail_id($post_type, $id, $post_id); | ||
| $attachment_meta = get_post($post_thumbnail_id); | ||
| return $attachment_meta->post_title; | ||
| } | ||
|
|
||
| /** | ||
| * | ||
| * @param string $post_type The post type. | ||
| * @param string $id The id used to register the thumbnail. | ||
| * @return thumbnail description. | ||
| */ | ||
| public static function get_post_thumbnail_description($post_type, $id) { | ||
| $post_id = get_the_ID(); | ||
| $post_thumbnail_id = self::get_post_thumbnail_id($post_type, $id, $post_id); | ||
| $attachment_meta = get_post($post_thumbnail_id); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Like above an you check to make sure |
||
| return $attachment_meta->post_excerpt; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we use |
||
| } | ||
|
|
||
| /** | ||
| * Output the post thumbnail HTML for the metabox and AJAX callbacks | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR! Can you check to make sure
$post_thumbnail_idis valid here before doingget_post()? Making sure it is an int greater than zero should cover it. If it isn't valid, returning a blank string seems appropriate.