Plugin does not handle apostrophe in image label
-
Hi,
I faced an issue when labeling the picture with text containing apostrophe. When you save or update it the gallery is just lost.To solve this issue there are several ways. But, I choose to sanitize the image label by modifying in lightbox-slider.php the function called light_box_meta_save()
$name = $_POST[‘image_label’.$i];
replaced by
$name = cleanstr($_POST[‘image_label’.$i]);
update_post_meta($post_ID, ‘image_label’.$i, $name);
and adding a function cleanstr which is
function cleanstr($string) {
$string = preg_replace(‘/[^A-Za-z0-9\-\,\s]/’, ‘ ‘, $string); // Removes special chars keeping space and comma.
return preg_replace(‘/-+/’, ‘-‘, $string); // Replaces multiple hyphens with single one.
}
If this solution works, a more skillful approach would be to use form validation.
Regards,
- The topic ‘Plugin does not handle apostrophe in image label’ is closed to new replies.