standardebooks / web

The source code for the Standard Ebooks website.
https://standardebooks.org
Creative Commons Zero v1.0 Universal
234 stars 61 forks source link

Correct errors found in #336 #370

Closed colagrosso closed 3 months ago

colagrosso commented 3 months ago

There are a few functions like this one that I had to leave as returning ?string because of the file_exists() call. I considered returning an empty string in that case, but I decided not to.

    protected function GetHeroImage2xAvifUrl(): ?string{
        if($this->_HeroImage2xAvifUrl === null){
            if(file_exists(WEB_ROOT . '/images/covers/' . $this->UrlSafeIdentifier . '-hero@2x.avif')){
                $this->_HeroImage2xAvifUrl = '/images/covers/' . $this->UrlSafeIdentifier . '-' . $this->GetLatestCommitHash() . '-hero@2x.avif';
            }
        }
        return $this->_HeroImage2xAvifUrl;
    }
acabal commented 3 months ago

Looks good, thanks!