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

avatar_fallback_image is optional and causes problems in AvatarFileUpload::generate #45

Open
fritzmg opened this issue Oct 27, 2015 · 2 comments

Comments

@fritzmg
Copy link

fritzmg commented Oct 27, 2015

Since the fallback image is optional, the following code causes problems:

if(count($arrValues) === 0)
{
  $objFile = \FilesModel::findByPath($GLOBALS['TL_CONFIG']['avatar_fallback_image']);    
  $strInfo = $objFile->path . ' <span class="tl_gray">(' . $this->getReadableSize($objFile->size) . ($objFile->isGdImage ? ', ' . $arrImage[0] . 'x' . $arrImage[1] . ' px' : '') . ')</span>';
  $arrValues[$objFile->uuid] = \Image::getHtml(\Image::get($objFile->path, $arrImage[0], $arrImage[1], $arrImage[2]), '', 'class="gimage" title="' . specialchars($strInfo) . '"');
}

in AvatarFileUpload.php#L181. When no fallback image is set, there will be an error whenever the widget is generated for a user, that does not have an avatar image set. It should instead say

if(count($arrValues) === 0)
{
  if(($objFile = \FilesModel::findByPath($GLOBALS['TL_CONFIG']['avatar_fallback_image'])) !== null)
  {    
    $strInfo = $objFile->path . ' <span class="tl_gray">(' . $this->getReadableSize($objFile->size) . ($objFile->isGdImage ? ', ' . $arrImage[0] . 'x' . $arrImage[1] . ' px' : '') . ')</span>';
    $arrValues[$objFile->uuid] = \Image::getHtml(\Image::get($objFile->path, $arrImage[0], $arrImage[1], $arrImage[2]), '', 'class="gimage" title="' . specialchars($strInfo) . '"');
  }
}
@katgirl
Copy link
Owner

katgirl commented Oct 27, 2015

is in Master and develop fixed

@katgirl katgirl closed this as completed Oct 27, 2015
@fritzmg
Copy link
Author

fritzmg commented Oct 27, 2015

Well, you are just checking for

$GLOBALS['TL_CONFIG']['avatar_fallback_image'] != ''

But if the file gets deleted, it will again lead to an error. Actually you would neet both the null check and a file_exists check.

@katgirl katgirl reopened this Nov 18, 2015
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