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

Call to a member function media() on null #79

Open
tranduyhung opened this issue Nov 23, 2019 · 1 comment
Open

Call to a member function media() on null #79

tranduyhung opened this issue Nov 23, 2019 · 1 comment

Comments

@tranduyhung
Copy link

In seoGetimage function in seo.php, line 78 creates the error Call to a member function media() on null if the page of image is not found:

$imgarray = $this->grav['page']->find($fixedurl)->media()->images();

To fix this, we need to check if the page exists or not first, something like this:

$page = $this->grav['page']->find($fixedurl);

if (!$page)
    return [
        'url'       => '',
        'width'     => '',
        'height'    => '',
    ];

$imgarray = $page->media()->images();

Because I am not familiar with this plugin so I don't know if returning empty URL, width and height would effect somewhere else or not, so I don't submit a pull request for this, at least with this simple fix the error is gone and the site's running again.

@danjames68
Copy link

I also get this error when using the microdata section - if I turn the microdata off the page renders properly, if I turn any of them on the page throws an empty $imgarray error. I've just discovered this, will investigate over the next days.

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