Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7675247
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T16:55:07+00:00 2026-05-31T16:55:07+00:00

My application allows users to upload an image with embedded captions. These captions are

  • 0

My application allows users to upload an image with “embedded” captions. These captions are taken from the exif data:

foreach (exif_read_data('image.jpg', 0, true) as $key => $section) {
    foreach ($section as $name => $val) {
        if ($key == 'IFD0' && $name == 'Title') {
            $caption = $val;
            break;
        }
    }
    if ($caption !== '') { break; }
}
//save $caption to database

The images are displayed along with their captions. Each image’s caption is rendered 2 times:

  1. title attribute of an <a> that is wrapped around the image
  2. in a div that contains the caption

This is the result:

<a title="T?h?i?s? ?i?s? ?a? ?c?a?p?t?i?o?n?" href="#"><img src="image.jpg"></a>
<div class="caption">This is a caption.</div>

As you can see, when the caption is inside the title attribute, question marks appear. Why is this so?

I would note that I have made the whole application work with utf8 (database, html pages). I have also tried to utf8_encode() the extracted caption before saving it into the database, to no avail.

Any ideas?

EDIT:
By the way, the reason for using an <a> is so that the image appears in a jQuery lightbox when clicked.

EDIT:
@tpaksu, here is an actual dump of the result of exif_read_data('image.jpg', 0, true)

Array
(
    [FILE] => Array
        (
            [FileName] => 174.jpg
            [FileDateTime] => 1332196128
            [FileSize] => 236179
            [FileType] => 2
            [MimeType] => image/jpeg
            [SectionsFound] => ANY_TAG, IFD0, EXIF, GPS, WINXP
        )

    [COMPUTED] => Array
        (
            [html] => width="640" height="427"
            [Height] => 427
            [Width] => 640
            [IsColor] => 1
            [ByteOrderMotorola] => 1
            [CCDWidth] => 9mm
            [ApertureFNumber] => f/11.0
            [UserComment] => 
            [UserCommentEncoding] => UNDEFINED
        )

    [IFD0] => Array
        (
            [ImageDescription] => STATE OF CALAMITY/FEB. 2, 2012: Firemen and residents of sitio San Roque in Talisay City help each other in putting off the fire. The Talisay City council wants to declare sitio Laray in a state of calamity.(CDN PHOTO/JUNJIE MENDOZA)
            [Make] => Canon
            [Model] => Canon EOS 50D
            [Orientation] => 1
            [Software] => Adobe Photoshop CS2 Windows
            [DateTime] => 2012:02:04 18:54:15
            [YCbCrPositioning] => 1
            [UndefinedTag:0x1001] => 4752
            [UndefinedTag:0x1002] => 3168
            [Exif_IFD_Pointer] => 2544
            [GPS_IFD_Pointer] => 5304
            [Title] => S�T�A�T�E� �O�F� �C�A�L�A�M�I�T�Y�/�F�E�B�.� �2�,� �2�0�1�2�:� �F�i�r�e�m�e�n� �a�n�d� �r�e�s�i�d�e�n�t�s� �o�f� �s�i�t�i�o� �S�a�n� �R�o�q�u�e� �i�n� �T�a�l�i�s�a�y� �C�i�t�y� �h�e�l�p� �e�a�c�h� �o�t�h�e�r� �i�n� �p�u�t�t�i�n�g� �o�f�f� �t�h�e� �f�i�r�e�.� �T�h�e� �T�a�l�i�s�a�y� �C�i�t�y� �c�o�u�n�c�i�l� �w�a�n�t�s� �t�o� �d�e�c�l�a�r�e� �s�i�t�i�o� �L�a�r�a�y� �i�n� �a� �s�t�a�t�e� �o�f� �c�a�l�a�m�i�t�y�.�(�C�D�N� �P�H�O�T�O�/�J�U�N�J�I�E� �M�E�N�D�O�Z�A�)���
            [Subject] => S�T�A�T�E� �O�F� �C�A�L�A�M�I�T�Y�/�F�E�B�.� �2�,� �2�0�1�2�:� �F�i�r�e�m�e�n� �a�n�d� �r�e�s�i�d�e�n�t�s� �o�f� �s�i�t�i�o� �S�a�n� �R�o�q�u�e� �i�n� �T�a�l�i�s�a�y� �C�i�t�y� �h�e�l�p� �e�a�c�h� �o�t�h�e�r� �i�n� �p�u�t�t�i�n�g� �o�f�f� �t�h�e� �f�i�r�e�.� �T�h�e� �T�a�l�i�s�a�y� �C�i�t�y� �c�o�u�n�c�i�l� �w�a�n�t�s� �t�o� �d�e�c�l�a�r�e� �s�i�t�i�o� �L�a�r�a�y� �i�n� �a� �s�t�a�t�e� �o�f� �c�a�l�a�m�i�t�y�.�(�C�D�N� �P�H�O�T�O�/�J�U�N�J�I�E� �M�E�N�D�O�Z�A�)���
            [UndefinedTag:0xEA1C] => �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������
        )

    [EXIF] => Array
        (
            [ExposureTime] => 1/125
            [FNumber] => 11/1
            [ISOSpeedRatings] => 400
            [ExifVersion] => 0221
            [DateTimeOriginal] => 2012:02:02 12:40:00
            [DateTimeDigitized] => 2012:02:02 12:40:00
            [ComponentsConfiguration] => �
            [ShutterSpeedValue] => 458752/65536
            [ApertureValue] => 458752/65536
            [ExposureBiasValue] => 0/1
            [Flash] => 16
            [FocalLength] => 16/1
            [UserComment] => ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������
            [SubSecTimeOriginal] => 00
            [SubSecTimeDigitized] => 00
            [FlashPixVersion] => 0100
            [ColorSpace] => 1
            [ExifImageWidth] => 2000
            [ExifImageLength] => 1333
            [FocalPlaneXResolution] => 4752000/894
            [FocalPlaneYResolution] => 3168000/597
            [FocalPlaneResolutionUnit] => 2
            [CustomRendered] => 0
            [ExposureMode] => 1
            [WhiteBalance] => 0
            [SceneCaptureType] => 0
            [UndefinedTag:0xEA1C] => �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������
        )

    [GPS] => Array
        (
            [GPSVersion] => ��
        )

    [WINXP] => Array
        (
            [Title] => STATE OF CALAMITY/FEB. 2, 2012: Firemen and residents of sitio San Roque in Talisay City help each other in putting off the fire. The Talisay City council wants to declare sitio Laray in a state of calamity.(CDN PHOTO/JUNJIE MENDOZA)
            [Subject] => STATE OF CALAMITY/FEB. 2, 2012: Firemen and residents of sitio San Roque in Talisay City help each other in putting off the fire. The Talisay City council wants to declare sitio Laray in a state of calamity.(CDN PHOTO/JUNJIE MENDOZA)
        )

)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T16:55:08+00:00Added an answer on May 31, 2026 at 4:55 pm

    Ok try this inside your code.

     if ($key == 'IFD0' && $name == 'Title') {
         if(strpos($val,"�")>0){
             for($i=0;$i<len($val);$i++){
                 $newval.=$val[i];
                 $i++;
             }
         }
         $caption = $val;
         break;
     }
    

    or

     if ($key == 'IFD0' && $name == 'Title') {
         $caption = preg_replace('/[^(\x20-\x7F)]*/','', $val);
         break;
     }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working on a web application that allows users to upload attachments. These
I have an application that allows users to upload files. Some of these files
My web application allows end users to upload image. After the image is saved
I'm writing an application that allows users to upload images onto the server. I
Let say, I have a web application that allows users to upload images and
Part of an application I'm writing allows for users to upload images which I
My ASP.NET application allows users to upload and download large files. Both procedures involve
We have created a web application, using ASP.NET, that allows users to upload documents
Our application allows users to upload javascript, CSS, and HTML files. We need a
I have an application that allows users to upload images. The test case I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.