You can simply use your auto_increment image id, for example, converted to base58 (a-zA-Z0-9).
base_convert can convert to base36:
$id = base_convert(123456789, 10, 36); // "21i3v9"
(See also PHP - How to base_convert () to base 62 )
If you want non-predictable image identifiers, see this answer .
For MongoDB IDs (how do you use MongoDB):
An id is 12 bytes of numbers encoded to base16, which makes them 24 bytes.
You can compress them to 17 bytes by converting them from base16 to base58:
gmp_strval(gmp_init("47cc67093475061e3d95369d", 16), 58)); // "1KXotnQBQbcPmeOo9"
Also take a look at the "Sequence Numbers" section here . This will allow you to create smaller unique numbers for your images.
arnaud576875
source share