/** * Displays a link to current post author profile page * @param string $text * @param string $class * @param bool $echo */ function the_fa_author_link($text = '', $class = '', $echo = true) { $post = get_current_slide(); if (!$post) { return; } $author_id = $post->post_author; $author_url = get_author_posts_url($author_id); if (!$author_url) { return; } $user_data = get_userdata($author_id); if (!$user_data) { return; } if (empty($text)) { $text = $user_data->display_name; } $css_class = !empty($class) ? ' class="' . $class . '"' : ''; $result = sprintf('<a href="%s" title="%s"%s>%s</a>', $author_url, $user_data->display_name, $css_class, $text); if ($echo) { echo $result; } return $result; }
/** * Returns the image URL for a given slide ID ( $post_id ) that belongs to * a given slider id( $slider_id ). Will do all size checking and will return * an array with the image details or false if image isn't found. * * @param int $post_id - ID of slide * @param int $slider_id - ID of slider * @return array( 'url' => URL of image, 'width' => image width, 'height' => image height, 'id' => image ID if found in media gallery ) */ function get_the_fa_slide_image_url($post_id = false, $slider_id = false) { // get the slider ID if (!$slider_id) { global $fa_slider; if ($fa_slider) { $slider_id = $fa_slider->ID; } else { _doing_it_wrong('get_the_fa_image_url()', __('Use this function inside a slide loop or pass the slider ID to the function.', 'fapro'), '3.0'); } } // set the post ID if (!$post_id) { if (isset($fa_slider)) { $post = get_current_slide(); } else { global $post; } if ($post) { $post_id = $post->ID; } else { _doing_it_wrong('get_the_fa_image_url()', __('Use this function inside a slide loop or pass the slide (post) ID to the function.', 'fapro'), '3.0'); } } else { $post = get_post($post_id); } if (!$post || !$post_id || !$slider_id) { return false; } // get slider options and check if image is visible $slider_options = fa_get_slider_options($slider_id, 'content_image'); if (!$slider_options['show']) { return; } // slide options $options = fa_get_slide_options($post_id); // get the attached image ID $image_id = get_the_fa_image_id($post_id); // try to make the image url $image_url = false; if ('wp' == $slider_options['sizing'] && $image_id) { $wp_attachment = wp_get_attachment_image_src($image_id, $slider_options['wp_size']); if ($wp_attachment) { $image_url = $wp_attachment[0]; } } else { if ('custom' == $slider_options['sizing'] && $image_id) { $image_url = fa_get_custom_image_size($image_id, $slider_options['width'], $slider_options['height']); } } // last options, check on slide settings if an image URL is set if (!$image_url) { if (isset($options['temp_image_url']) && !empty($options['temp_image_url'])) { $image_url = $options['temp_image_url']; } else { // try to autodetect the image URL in post content if option is enabled $plugin_options = fa_get_options('settings'); if (isset($plugin_options['allow_image_autodetect']) && $plugin_options['allow_image_autodetect']) { $current_post = get_post($post_id); if ($current_post) { $image = fa_detect_image($current_post->post_content); if (!$image['id'] && $image['img']) { $image_url = $image['img']; fa_update_slide_options($post_id, array('temp_image_url' => $image_url)); } } } } } // if no image URL was detected, stop if (!$image_url) { return false; } $width = $height = false; // get the image size if ('custom' == $slider_options['sizing']) { $width = absint($slider_options['width']); $height = absint($slider_options['height']); } elseif ('wp' == $slider_options['sizing']) { if (isset($wp_attachment) && $wp_attachment) { $width = $wp_attachment[1]; $height = $wp_attachment[2]; } } // create the response return array('url' => $image_url, 'width' => $width, 'height' => $height, 'id' => $image_id); }