I am currently developing a script that requires images stored into Mongo with GridFS, although when the files are being retrieved (with a php header) the width=”” and height=”” HTML is already placed into the display, is there any way I change this or store it within Mongo/GridFS?
// get GridFS files collection
$grid = $db->getGridFS();
// retrieve file from collection
$file = $grid->findOne(array('_id' => new MongoId('4fb437dbee3c471b1f000001')));
// send headers and file data
header('Content-Type: image');
echo $file->getBytes();
exit;
PHP won’t add those width and height tags itself. It might be something that your browser adds for you though so please check what is actually send across the wire!
In any case, when you store a file in GridFS, you can set extra meta data:
In order to make use of this information, you will have to do a separate query that queries this, and then injects it into your HTML code. A query to get the meta data can be with: