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

(PHP) Cannot override emojiVersion or emojiSize #55

Open
tadhgboyle opened this issue Feb 28, 2023 · 0 comments
Open

(PHP) Cannot override emojiVersion or emojiSize #55

tadhgboyle opened this issue Feb 28, 2023 · 0 comments

Comments

@tadhgboyle
Copy link

Hi there,

I would have expected this code:

$client = new Client();
$client->emojiSize = 64;
echo $client->toImage('😀');

To produce <img class="joypixels" alt="😀" title=":grinning:" src="https://cdn.jsdelivr.net/joypixels/assets/7.0/png/unicode/64/1f600.png">, since the code is documented to say we can set emojiSize: "available sizes are '32', '64', and '128'", but instead it produced <img class="joypixels" alt="😀" title=":grinning:" src="https://cdn.jsdelivr.net/joypixels/assets/7.0/png/unicode/32/1f600.png">,.

public $emojiSize = '32'; // available sizes are '32', '64', and '128'

The issue is that since the imagePathPNG property is set in the constructor, it is too late use the emojiSize property on the $client instance.

$this->imagePathPNG = $this->imagePathPNG . '/' . $this->emojiVersion . '/png/unicode/' . $this->emojiSize . '/';

A workaround is this, but I believe the code should act different, since it's not possible to customize it by setting the public property:

$client = new class extends Client {
    public $emojiSize = '64';
};
echo $client->toImage('😀');
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

1 participant