Fix RLIKE, $attachmet[0], and autoembedding jpg

RLIKE did not work with "exotic" filename characters like "+"
$attachment[0] did not exist if the query returned 0 rows.
IF no media ID is found, and this is an autoembed attempt, and it is not a *.pdf file, do not embed it.