This `substr()` / `strlen()` approach is not very readable. Please replace them with a `preg_match()`.

Also, consider assigning to more meaningfull variable names, rather than using `$thumbnail[0]` and `$thumbnail[1]`.