I need to display <img src="http://my.pic/test/rg/pict.png" /> from `items`.`img`
But when res.write(rows[0].img, 'utf8');,
I see in browser:
<img style="display: none !important;" src="http://my.pic/test/rg/pict.png" />
How do I fix style="display: none !important;"?
express = require('express'), app = express();
var mysql = require('mysql');
app.listen(8080);
mysql.connect = function(req, res, next){
var connect = mysql.createConnection({
host : 'localhost',
user : 'person',
password : 'ppasw',
database : 'db1'
});
return connect;
}
server.get(new RegExp('/img'), function(req, res, next){
var db =mysql.connect();
db.connect();
db.query("use `bd1`");
db.query("SELECT `img` FROM `items` WHERE `id`='" + intval(req.query.id) + "'",
function (err, rows, fields) {
res.setHeader("Content-Type", "text/html");
res.write(rows[0].img, 'utf8');
res.end();
});
db.end();
});
----* I find problem - Adblock plugin.
Can you add this debug code before the res.write part ?
console.log(rows[0].img)
My best guess is that the style attribute is already in the database.
My second best guess is that you might have some javascript running in your browser which hides broken images.
Depending on the information on the database, you may have to construct the HTML. If you're only putting the URL to the image in there, it's not going to work right. You might have to do something like:
res.write('<html><body><img src="' + rows[0].img + '" /></body></html>');
If the database has all of the HTML already stored (I suggest not doing that) and you don't have any extensions hiding broken images, you're going to have to have some client side Javascript to unhide the image.