public function generateLink(AssetContainer $thumbnail = null)
    {
        // Check if thumbnail can be found
        if (!$thumbnail || !$thumbnail->exists() || !$thumbnail->getIsImage()) {
            return null;
        }

        // Ensure thumbnail doesn't exceed safe bounds
        $maxSize = $this->config()->get('max_thumbnail_bytes');
        if (!$thumbnail->getAbsoluteSize() > $maxSize) {
            return null;
        }

        // Determine best method to encode this thumbnail
        $urlRules = $this->config()->get('thumbnail_links');
        $visibility = $thumbnail->getVisibility();
        $urlRule = $urlRules[$visibility];
        if (!isset($urlRule)) {
            throw new LogicException("Invalid visibility {$visibility}");
        }

        // Build thumbnail
        switch ($urlRule) {
            case self::URL:
                return $thumbnail->getURL();
            case self::INLINE:
                // Generate inline content
                $base64 = base64_encode($thumbnail->getString());
                return sprintf(
                    'data:%s;base64,%s',
                    $thumbnail->getMimeType(),
                    $base64
                );
            default:
                throw new LogicException("Invalid url rule {$urlRule}");
        }
    }