Skip to content

Image::createLink doesn't return link with $basePath #23

@juniwalk

Description

@juniwalk

Hello,
I wanted to show image of user in datagrid, however Image::createLink method returns path without the $basePath variable.

public function columnName(User $user): Html
{
	$presenter = $this->getPresenter();
	$basePath = $presenter->getHttpRequest()->getUrl()->getBasePath();

	// Avatar
	$image = $this->imageStorage->fromIdentifier($user->getImage());
	$avatar = Html::el('img class="img-fluid img-circle mr-2" width="24px" alt="'.$user.'"')
		->setSrc($basePath.$image->createLink());

	// Link
	$link = $presenter->lazyLink('User:edit', $user->getId());
	$name = Html::el('a')->setHref($link)->addHtml($avatar)
		->addText($user->getName());

	return $name;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    Triage: Now

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions