我的应用程序允许用户上传带有“嵌入”标题的图像。这些标题取自 exif 数据:
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
图像与其标题一起显示。每个图像的标题都会渲染 2 次:
-
title
的属性<a>
包裹在图像周围
- in a
div
包含标题的
这是结果:
<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>
正如你所看到的,当标题位于title
属性,出现问号。为什么会这样呢?
我要指出的是,我已经使整个应用程序使用 utf8(数据库、html 页面)。我也尝试过utf8_encode()
在将其保存到数据库之前提取的标题,但无济于事。
有任何想法吗?
EDIT:顺便说一下,使用的原因<a>
以便单击时图像出现在 jQuery 灯箱中。
EDIT:@tpaksu,这是结果的实际转储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)
)
)