public function _add_image($admin_img = false) { $default_image = NY_OG_Main_Admin::option('image'); if (is_front_page()) { $home_image = NY_OG_Main_Admin::option('home_image'); if ($home_image) { $this->_metas['og:image'] = $home_image; } else { if ($default_image) { $this->_metas['og:image'] = $default_image; return $default_image; } } } else { if (is_home()) { $blog_image = NY_OG_Main_Admin::option('blog_image'); if ($home_image) { $this->_metas['og:image'] = $blog_image; } else { if ($default_image) { $this->_metas['og:image'] = $default_image; return $default_image; } } } else { if (has_post_thumbnail()) { $this->_metas['og:image'] = wp_get_attachment_url(get_post_thumbnail_id()); if ($admin_img) { $img = wp_get_attachment_image(get_post_thumbnail_id(), array(50, 50)); return $img; } return wp_get_attachment_url(get_post_thumbnail_id()); } else { $attachment = get_posts(array('numberposts' => 1, 'post_type' => 'attachment', 'post_parent' => get_the_ID())); if ($attachment) { $this->_metas['og:image'] = wp_get_attachment_thumb_url($attachment[0]->ID); if ($admin_img) { $img = wp_get_attachment_image($attachment[0]->ID, array(50, 50)); return $img; } return wp_get_attachment_thumb_url($attachment[0]->ID); } else { if ($default_image) { $this->_metas['og:image'] = $default_image; if ($admin_img) { return '<img width="50" src="' . $default_image . '" />'; } return $default_image; } else { return false; } } wp_reset_query(); } } } }
</textarea> </td> <tr> <td> <label for="og_blog_type">Type:</label><br /> <em>(article / blog / website etc.)</em> </td> <td> <input type="text" style="width:510px;" id="og_blog_type" name="wpog_options[blog_type]" value="<?php echo NY_OG_Main_Admin::option('blog_type'); ?> " size="90" /> </td> </tr> <tr> <td><label for="og_blog_image">Image URL:</label></td> <td> <input type="text" style="width:510px;" id="og_blog_image" name="wpog_options[blog_image]" value="<?php echo NY_OG_Main_Admin::option('blog_image'); ?> " size="90" /> </td> </tr> </table> <p class="submit"> <input type="submit" class="button-primary" value="<?php _e('Submit'); ?> " /> </p> </form>