Jeżeli to o czym piszę jest nie w temacie, bądź nie powinienem o to pytać, to przepraszam i proszę o zamknięcie tematu.
Mam problem. Na serwerze zablokowane jest url_fopen i zdjęcia na stronie nie wyświetlają się.
Instrukcja warunkowa w skrypcie szablonu niestety nie działa i nie ciągnie zdjęć poprzez cURL.
Przedstawiam kod pliku, który wywala następujący błąd
Warning: get_headers(): http:// wrapper is disabled in the server configuration by allow_url_fopen=0 in /home/users/webs/xxx/wp-content/themes/im-startup/framework/functions/image_cache.php on line 314
A tutaj kod:
<?php ..... if ( ! function_exists( 'miss_image_by_attachment' ) ) { function miss_image_by_attachment() { 'post_parent' => get_the_ID(), 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => 'ASC', 'orderby' => 'menu_order ID', 'numberposts' => 1 )); return false; foreach ( $attachments as $id => $attachment ) { $image = wp_get_attachment_image_src( $id, '' ); $image_tags = miss_post_image_tags( $id ); $alt = $image_tags['alt']; } } } /** * */ if ( ! function_exists( 'miss_post_image_tags' ) ) { function miss_post_image_tags( $image_id, $post_id = '' ) { # Check to is if attachment image has alt $alt = ''; $file_name = ''; $alt = get_post_meta( $image_id, '_wp_attachment_image_alt', true ); } # If no alt generate from file name $file = get_attached_file( $image_id ); } # Generate title tag from post title $title = ''; $title = esc_attr( apply_filters( 'the_title', get_post_field( 'post_title', $post_id ) ) ); } } /** * */ if ( ! function_exists( 'miss_display_image' ) ) { } return '<img src="' . miss_wp_image( THEME_IMAGES_ASSETS . '/general/no-thumbnail.png' , $width, $height ) . '" />'; } return; } { $out = miss_video( array( 'url' => $video_src, 'width' => $width, 'height' => $height, 'parse' => true, 'video_controls' => $video_controls ) ); } else { $image = $src; //Trying to build array from string //$home_url = get_home_url() . '/'; $home_url = home_url( '/' ); } //For local images // In this case we'll define image ABSOLUTE PATH // $image_path = $_SERVER['DOCUMENT_ROOT'] . $image_path[1]; $image_path = ABSPATH . $image_path[1]; } else { // In this case we'll define iamge URI if( function_exists('curl_init') ) { $image_path = $image; //if allow_url_fopen is off trying to reach curl Linia 314->> $image_headers = get_headers( $image, 1 ); if ( $image_headers['Content-Type'] == "image/jpeg" ) { $remote_extrnsion = ".jpg"; } if ( $image_headers['Content-Type'] == "image/gif" ) { $remote_extrnsion = ".gif"; } if ( $image_headers['Content-Type'] == "image/png" ) { $remote_extrnsion = ".png"; } // Crete safe index } } $image_downloads = THEME_CACHE . '/donwloads'; } else { $image_downloads = THEME_CACHE; } // Trying to reach local file } else { $ch = curl_init ( $image ); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1); $image_raw_data = curl_exec($ch); curl_close ($ch); //Unlinking if file exists } // $fp = fopen($image_downloads,'x'); // fwrite($fp, $image_raw_data); // fclose($fp); $image_path = $image_downloads; } } } else { } } ... ?>
Proszę o pomoc, bo już nie wiem co mam robić, a deadline projektu się kończy :/