On node save the notice Notice: getimagesize() [function.getimagesize]: Read error! in image_gd_get_info() (line 349 of C:\wamp\www\store\modules\system\image.gd.inc) is created and the thumbnail image does not show.

I have attached four images from the debugging program that include the variable values. The first two images, media_youtube_bug1.jpg and media_youtube_bug2.jpg are from when the youtube link is added through the media dialog and the user is returned to the node edit or node create page. The last two images, media_youtube_bug3.jpg and media_youtube_bug4.jpg, are from when the user clicks the save button on the node edit or node create form. I have no other information than the site being relatively vanilla and I'm using the latest dev version of Media and Media Youtube modules.

#40 core-getimagesize_read_error-1522348-40.patch522 bytesseanB
PASSED: [[SimpleTest]]: [MySQL] 40,901 pass(es). View
#21 core-getimagesize_read_error-1522348-21.patch587 bytesjenlampton
PASSED: [[SimpleTest]]: [MySQL] 39,559 pass(es). View
media_youtube_bug4.jpg198.45 KBAdam S
media_youtube_bug3.jpg202.76 KBAdam S
media_youtube_bug2.jpg211.04 KBAdam S
media_youtube_bug1.jpg178.42 KBAdam S
Members fund testing for the Drupal project. Drupal Association Learn more


sethhill’s picture

Getting this too. As a workaround I changed the widget type to file and used it that way. It won't let you link to the content as easily in Views, but you can do a token replacement and link to node/[nid].

Christian Bj’s picture

i have the same problem

Adam S’s picture

I changed the field type to file and with the latest version of media.module it allows YouTube to be embedded.

aethr’s picture

I chimed in with some details here, but the problem was a PEBCAC. I had selected the "Image" field type instead of File when setting up my content type, just as the other people above.

gooddesignusa’s picture

I need to use image since it provides max and min sizes for images. I have a field set up to allow image uploads or youtube links.

VanD’s picture

I am getting this error too, and using Media: YouTube with TinyMCE + WYSIWYG

Notice: getimagesize() [function.getimagesize]: Read error! in image_gd_get_info() (line 349 of /var/web/modules/system/image.gd.inc).

EDIT: Mine is unrelated -- Error caused by disk being full

paddy_deburca’s picture

Issue #681042: Notice when viewing an uploaded image of 0 bytes is a duplicate of this post. There is a suggested fix on line 349 of "modules/system/image.gd.inc" of

if (filesize($image->source)) {
  $data = getimagesize($image->source);

It seems that the proposed fix should be applied to D8 first, then ported to D7.


Of course, $image->source is of the format public://image-name.type, and both file size() and getimagesize() require a full path name. Another option is to use the function drupal_realpath() as

$img = drupal_realpath($image->source);
if (filesize($img)) {
  $data = getimagesize($img);
ronanoutang’s picture


Please if you have the solution for Drupal 7 of this issue, help me... I fed up to see this message on my website

askandlearn’s picture

I am getting this error on a fresh installation of the Open Enterprise distribution before I even try to upload anything. How might I go about tracking down the cause and fixing it?

ronanoutang’s picture


I am beginner in PHP and I test a simple solution and it seems to work :
Just add @ before getimagesize function in order to eliminate the error message (see below) :

function image_gd_get_info(stdClass $image) {
$details = FALSE;
$data = @getimagesize($image->source);

RobW’s picture

Status: Active » Postponed (maintainer needs more info)

Let me get some more info before I look into this further:

  • Are those experiencing this error using a file field and the YouTube preview image formatter, or an image field as some have mentioned above?
  • What versions of the module are being used?
RobW’s picture

Version: 7.x-1.x-dev » 7.x-2.x-dev
Status: Postponed (maintainer needs more info) » Active

Bringing issue #1793526: gd getimagesize error here.

@druplicate, how is your file field set up? So far, I have been unable to reproduce this.

gooddesignusa’s picture

Create a Image Field and use 'Media file selector' for the widget. Inside the field settings check 'video' under 'Allowed remote media types' & enable youtube under 'Allowed URI schemes'.
Then turn on 'YouTube Preview Image' under '/admin/structure/file-types/manage/video/file-display/media_large'
Make sure the display fields is set to use that build mode. Add new content, use youtube link in the new field. save node and you will get that notice. Hope that helps recreate the notice.

RobW’s picture

I believe the problem is using an image field instead of a file field. M:YT was built to use file entity, not image module.

I'd prefer to keep this module file field specific. Why aren't file fields working for you?

SocialNicheGuru’s picture

i am using a filefield and getting the error when the image did not upload properly.

#7 worked for me.

RobW’s picture

@SocialNicheGuru, can you paste the exact error, and steps to reproduce, versions being used if possible?

druplicate’s picture

I have an image field. I could use a file field but the goal was to allow mixed media so that images and video would display together in the same slideshow. There may be another way to accomplish that using two separate fields in the same content type but I'm not sure how to do it off the top of my head.

RobW’s picture

@Druplicate, that is the purpose of file field, and Media in general. You can set your file field to accept video and images; I would try this before looking for the source of image field errors.

Image field and non-image media providers like YouTube were never meant to work together. If file field is failing somewhere that image field isn't, we can try and fix file field, but overall this issue might be a "won't fix".

gooddesignusa’s picture

Sorry if I was unclear before. The reason I am using the Image field with the media selector widget is because I need the 'Minimum image resolution' option which will only show on an image field. I'm allowing youtube videos to be used in that field as well. If there was another way to add some type of field validation I would not need to use an Image field.
The notice is not a big deal since I shut off php notices when going live with the site so the end user never sees the message.

druplicate’s picture

I tried using a file field and a video from Youtube and that renders ok without the error, but an uploaded image will not display, only the file name/link. The field format is set to "rendered file". There may be a bug in filefield.

If I insert the short URL for a Youtube video via the "Web" tab, there are no errors and the video displays and plays fine, but if I first search for and select a video via the "Youtube" tab, I get this error:
Notice: Undefined index: #validators in media_youtube_add_validate() (line 258 of /usr/local/www/apache22/data/sites/all/modules/media_youtube/media_youtube.module)

The Youtube tab in Media is known to have some issues and I have read that it won't be included in the first stable release of Media 2.

jenlampton’s picture

Title: On node save Notice: getimagesize() [function.getimagesize]: Read error! in image_gd_get_info() (line 349 of C:\wamp\www\store\m » Notice: getimagesize read error in image_gd_get_info() line 349
Project: Media: YouTube » Drupal core
Version: 7.x-2.x-dev » 7.x-dev
Component: Code » image system
Status: Active » Needs review
587 bytes
PASSED: [[SimpleTest]]: [MySQL] 39,559 pass(es). View

Updating project and status.
Please test this patch and let me know if it helps.

kaizerking’s picture

this patch did not work

vadbars@drupal.org’s picture


Alan Warren’s picture

Patch did not work for me either.

before patch
Notice: getimagesize() [function.getimagesize]: Read error! in image_gd_get_info() (line 350

Notice: getimagesize() [function.getimagesize]: Read error! in image_gd_get_info() (line 351 of

Probably something I have not configured?

Any help would be greatly appreciated..

Found the module.

For me it was Enterprise Blog Content. I will post there, but mercifully don't need it!

martinyde’s picture

The patch in #21 solved my issue.

Drupal 7.17
Media 7.x-1.2
Media Vimeo 7.x-1.0-Beta5
Media Youtube 7.x-2.0-rc1

Barry Tielkes’s picture

Image is showing up when using:
Drupal 7.17
Media 7.x-2.0-unstable7
Media Youtube 7.x-2.0-rc1
media_translation 7.x-1.2

But i still get the notice. (

aaron’s picture

Status: Needs review » Needs work

I applied the patch, and it does not solve the error when I have a youtube setup on the image field.

everoll’s picture

The @ in front of getimagesize fixed mine also. Thanks!!

j0rd’s picture

so function image_gd_get_info($image) calls getimagesize() on $image->source.

When using media_youtube $image->source is set to something like "youtube://v/wTaXI9LUugc"

Get image size obviously doesn't understand this URL. Which is why it fails.

I assume this is a problem with either media or media_youtube passing in the wrong / invalid data to image_get_info().

Spartagus’s picture

Any update on this error? I tried the patch with no luck.

I am using:
Drupal 7.22
Media 7.x-1.3
Media: YouTube 7.x-2.0-rc3

vacho’s picture

this problem in my case is for the permissions of files. this these should be at 777

b-a-l-d-e-r’s picture

• Patch did NOT work.
• #10 solved the issue for me

joco_sp’s picture

#21 worked for me

jenlampton’s picture

Status: Needs work » Reviewed & tested by the community

With several successful reviews above, looks like this patch is RTBC.

I'm still applying this patch to 7.23 so would love to get it in :)

jenlampton’s picture

Issue summary: View changes

My grammar sucks.

sgurlt’s picture

#21 didnt worked for me

#10 instead worked perfectly ! :)

geekyMoa’s picture

#21 gave me this error instead:

Warning: filesize() [function.filesize]: stat failed for http://youtube.com/watch?v=Tk4vRF5djkk i image_gd_get_info() (line 350 of modules/system/image.gd.inc).

betoscopio’s picture

David_Rothstein’s picture

Status: Reviewed & tested by the community » Needs review

It sounds like testing results on the latest patch are mixed, and it also needs more review since e.g. j0rd's comment in #29 suggests it may not even be a bug in Drupal core...

If it is a bug in core, the fix would need to go into Drupal 8 first.

jenlampton’s picture

Still applying #21 to 7.25. If anyone else has any ideas as to where the problem might be caused, please post your ideas. I'm happy to do some more digging in D7.

I can't do any work on D8 since there's still a horrible core bug that prevents me from running it, so if this needs to be fixed first there then someone else will have to roll that patch :(

seanB’s picture

522 bytes
PASSED: [[SimpleTest]]: [MySQL] 40,901 pass(es). View

I added a patch for the fix in #10.

rajeev_drupal’s picture

Status: Needs review » Reviewed & tested by the community

Worked for me.......Making status RTBT

fietserwin’s picture

In D8 this is (soon) going to be solved by #2211227: Refactor image and imagetoolkit: isExisting, isSupported, supportedTypes, getMimeType, so no need to first solve this issue in D8.

A few notes:
- What we do solve in D8 is just preventing the error message from appearing. As the method that calls getimagesize() returns false we expect the calling code to display a proper user oriented error message. This is in line with the patch in #40.
- getimagesize() can work with stream wrappers, so there is no need to use drupal_realpath to get the actual file name (patch in #21 is not needed). The Drupal stream wrappers do implement stream_stat() and url_stat() and so won't fail either. If stat() fails for the youtube stream wrapper (comment #36), that error message will also be prevented by the @. This is also in lien with the patch in #40.

So a +1 on RTBC for patch #40.

David_Rothstein’s picture

Status: Reviewed & tested by the community » Fixed

Alright, thanks for that info. I think we can commit this now, due to the timing (but keep an eye on the Drupal 8 issue and forward-port this one-line change if something happens such that it becomes necessary).

Committed to 7.x - thanks!

  • Commit 9d55871 on 7.x by David_Rothstein:
    Issue #1522348 by seanB, jenlampton | Adam S: Notice: getimagesize read...
David_Rothstein’s picture

Status: Reviewed & tested by the community » Fixed

No idea why this still shows up as RTBC when I marked it fixed above..

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.