Hej wszystkim,
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() {
$attachments = get_children
(array( 'post_parent' => get_the_ID(),
'post_status' => 'inherit',
'post_type' => 'attachment',
'post_mime_type' => 'image',
'order' => 'ASC',
'orderby' => 'menu_order ID',
'numberposts' => 1
));
if ( empty( $attachments ) ) 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'];
}
return array( 'url' => $image[0], 'alt' => $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 );
$alt = esc_attr
(trim( $alt )); }
# If no alt generate from file name
$file = get_attached_file( $image_id );
if( isset( $info['extension'] ) ) $file_name = basename( $file, '.' . $info['extension'] );
if( !empty( $file_name ) ) }
# Generate title tag from post title
$title = '';
$title = esc_attr( apply_filters( 'the_title', get_post_field( 'post_title', $post_id ) ) );
return array( 'title' => $title, 'alt' => $alt ); }
}
/**
*
*/
if ( ! function_exists( 'miss_display_image' ) ) {
function miss_display_image
( $args = array() ) { define( 'THEME_HIRES', ( ( miss_get_setting
('hires') == 'enabled') ? 2
: 1
) ); }
global $wp_query, $irish_framework_params;
$noimage = isset( $noimage ) ?
$noimage : false;
if ( ( empty( $src ) && empty( $video_src ) && $noimage == true ) || ( empty( $src ) && empty( $video_src ) && !is_single
() ) ) { 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( '/' );
if ( defined('ICL_LANGUAGE_CODE') ) { $home_url = str_replace('/' . ICL_LANGUAGE_CODE
. '/','/',$home_url); }
$image_path = explode( $home_url, $image );
//For local images
if( !empty( $image_path[1] ) ) { // 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";
}
if ( @mkdir( THEME_CACHE
. '/downloads' ) ) { // Crete safe index
@touch( THEME_CACHE
. '/downloads/index.html' ); }
}
$image_downloads = THEME_CACHE . '/donwloads';
} else {
$image_downloads = THEME_CACHE;
}
// Trying to reach local file
if ( file_exists( $image_downloads . '/' . md5( $image ) . $remote_extension ) ) { $image_path = $image_downloads . '/' . md5( $image ) . $remote_extension; } else {
if ( isset( $remote_extension ) && !empty( $remote_extension ) ) { $image_downloads .= '/' . md5( $image ) . $remote_extension;
$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 :/