通过使用以下代码,我像 "http://localhost..."
一样获得了图像URL,但是我需要该图像的root路径从 "var/www/html/.... "
$FeaturedImage = wp_get_attachment_image_src( get_post_thumbnail_id(
$post->ID ), 'homepage-column1' );
有什么方法可以获取缩略图后的根路径?
尝试以下:
$FeaturedImage = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID ),'homepage-column1' );
$uploads = wp_upload_dir();
$file_path = str_replace( $uploads['baseurl'], $uploads['basedir'], $FeaturedImage);