Fixed Image gallery metadata not saved if encoding errors are encountered

Timmie

Active member
The metadata is still not being displayed when images are uploaded into a mirrored forum thread with XFMG 2.2.0. Have these changes / fix been incorporated already or will they be in XFMG 2.2.1 when released?
 
The metadata is working fine for me, both from uploading into a media gallery category and uploading into a mirrored forum (XF 2.2.1 and XFMG 2.2.0)
 
The metadata is working fine for me, both from uploading into a media gallery category and uploading into a mirrored forum (XF 2.2.1 and XFMG 2.2.0)
Strange. It's definitely not working for me on my test site with XF 2.2.1 and XFMG 2.2.0. If I upload an image with metadata to the gallery then the metadata is displayed, but if I attach the same image to a mirrored forum the metadata is not displaying.
 
If you have commenting disabled, it may not appear in the new lightbox sidebar but it will appear in the full media view.

For example, it may not appear in this location:

1603454517357.webp

But if you click the 1603454574142.webp icon it will appear in the full media view:

1603454602335.webp

This will likely be fixed in the next release but we haven't fixed it yet. You can track that bug report here:

 
Many thanks Chris.

I do have comments enabled but the metadata is still not showing for attachments.

Also when I click that icon from within a forum it loads the image in a new window, it doesn't load the full media view. If I click the same icon from the mirrored image in the gallery then it does load the full media view, but the metadata is still missing. I know the metadata is embedded for the image as if I upload it directly to the gallery it displays correctly.

You should be able to view this forum and thread to see for yourself:

If you check the media gallery you'll see two images. The mirrored one without metadata and the direct gallery upload that displays the metadata.
 
When uploaded attachments are resized, they lose EXIF data and by the time they are mirrored (in XFMG\XF\Attachment\Post::onNewAttachment(Attachment $attachment, \XF\FileWrapper $file) they have been resized.
 
I see the issue now When uploading this image to posts the j`son_encode() call in \XFMG:Media\MirrorManager::insertAttachmentExif` service fails. When json_last_error_msg() is added to get a meaningful message on why this is failing, it returns "Malformed UTF-8 characters, possibly incorrectly encoded".

So switching:
PHP:
        if ($exif)
        {
            $this->db()->insert('xf_mg_attachment_exif', [
                'attachment_id' => $attachment->attachment_id,
                'attach_date' => $attachment->attach_date,
                'exif_data' => json_encode($exif)
            ], false, 'exif_data = VALUES(exif_data)');
        }
with:
PHP:
        if ($exif)
        {
            $this->db()->insert('xf_mg_attachment_exif', [
                'attachment_id' => $attachment->attachment_id,
                'attach_date' => $attachment->attach_date,
                'exif_data' => $this->em()->encodeValueForSource(\XF\Mvc\Entity\Entity::JSON, $exif)
            ], false, 'exif_data = VALUES(exif_data)');
        }
fixed the issue.

Yes, but the EXIF data has already been captured in the FileWrapper.
Yup, you're right.
 
Thank you for reporting this issue, it has now been resolved. We are aiming to include any changes that have been made in a future XFMG release (2.2.1).

Change log:
When inserting EXIF data from mirrored attachments, avoid JSON encoding errors with malformed characters.
There may be a delay before changes are rolled out to the XenForo Community.
 
Back
Top Bottom