Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add fallback for file_get_contents() #79

Open
jeroendesloovere opened this issue Oct 20, 2016 · 1 comment
Open

Add fallback for file_get_contents() #79

jeroendesloovere opened this issue Oct 20, 2016 · 1 comment

Comments

@jeroendesloovere
Copy link
Owner

Somebody had errors using addMedia() and "file_get_contents()" (#75)
So maby we should add a fallback like in this example

@claytoncollie
Copy link

claytoncollie commented Sep 6, 2017

I'm not the greatest with github just yet.

in VCard.php, replace lines 231-235 with

`

    if (function_exists('curl_version')) {

        $curl = curl_init();
        curl_setopt($curl, CURLOPT_URL, $url);
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
        $value = curl_exec($curl);
        curl_close($curl);

    } elseif (file_get_contents(__FILE__) && ini_get('allow_url_fopen')) {

        $value = file_get_contents($url);

    } else {

        throw new VCardMediaException('Nothing returned from URL.');
        
    }

`

Had to do this for sites hosted on WP Engine.

jeroendesloovere added a commit that referenced this issue Jul 3, 2018
Add fix for #75 and #79

If 'allow_url_fopen' is false on the hosting,
we now have an alternative way to download the image.
jeroendesloovere added a commit that referenced this issue Jul 3, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants