SVG code or image path for user avatar

I’m using this package:

There’s an option to automatically create an avatar as an SVG,

Avatar::create('Test User')->toSvg();

which turns to this

<svg xmlns="" width="100" height="100" viewBox="0 0 100 100"><circle cx="50" cy="50" r="49.5" stroke="#009688" stroke-width="1" fill="#009688" style="--darkreader-inline-stroke: #63fff0; --darkreader-inline-fill: #00786d;" data-darkreader-inline-stroke="" data-darkreader-inline-fill=""></circle><text font-size="48" fill="#FFFFFF" x="50%" y="50%" dy=".1em" style="line-height: 1; --darkreader-inline-fill: #e8e6e3;" alignment-baseline="middle" text-anchor="middle" dominant-baseline="central" data-darkreader-inline-fill="">TU</text></svg>

and save as a normal image

Avatar::create('Test User')->save('avatar.png');

I have a table column in the database called image.

Is it better to save the SVG code or the image path in the column image? What do you guys think?

This is a common question. Small images or pdf is simpler to store as “binary large objects” (search for blob). Bigger files are better to store outside the database IMO.

The advantage of blobs as a column is simplicity. Both storing, retrieving, backup and restore.

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.