Changing the image source using jQuery

You can use jQuery’s attr() function. For example, if your img tag has an id attribute of ‘my_image’, you would do this: <img id=”my_image” src=”first.jpg” alt=”Insert link 1 alt text here” /> Then you can change the src of your image with jQuery like this: $(“#my_image”).attr(“src”,”second.jpg”); To attach this to a click event, you could … Read more

How to display Base64 images in HTML

My suspect is of course the actual Base64 data. Otherwise it looks good to me. See this fiddle where a similar scheme is working. You may try specifying the character set. <div> <p>Taken from wikpedia</p> <img src=”data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAAAUA AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO 9TXL0Y4OHwAAAABJRU5ErkJggg==” alt=”Red dot” /> </div> You can try this Base64 decoder to see if your Base64 … Read more

Strange OutOfMemory issue while loading an image to a Bitmap object

To fix the OutOfMemory error, you should do something like this: BitmapFactory.Options options = new BitmapFactory.Options(); options.inSampleSize = 8; Bitmap preview_bitmap = BitmapFactory.decodeStream(is, null, options); This inSampleSize option reduces memory consumption. Here’s a complete method. First it reads image size without decoding the content itself. Then it finds the best inSampleSize value, it should be … Read more

Changing image size in Markdown

You could just use some HTML in your Markdown: <img src=”https://stackoverflow.com/questions/14675913/drawing.jpg” alt=”drawing” width=”200″/> Or via style attribute (not supported by GitHub) <img src=”https://stackoverflow.com/questions/14675913/drawing.jpg” alt=”drawing” style=”width:200px;”/> Or you could use a custom CSS file as described in this answer on Markdown and image alignment ![drawing](drawing.jpg) CSS in another file: img[alt=drawing] { width: 200px; }

How to vertically align an image inside a div

The only (and the best cross-browser) way as I know is to use an inline-block helper with height: 100% and vertical-align: middle on both elements. So there is a solution: http://jsfiddle.net/kizu/4RPFa/4570/ .frame { height: 25px; /* Equals maximum image height */ width: 160px; border: 1px solid red; white-space: nowrap; /* This is required unless you … Read more

How do I auto-resize an image to fit a ‘div’ container?

Do not apply an explicit width or height to the image tag. Instead, give it: max-width:100%; max-height:100%; Also, height: auto; if you want to specify a width only. Example: http://jsfiddle.net/xwrvxser/1/ img { max-width: 100%; max-height: 100%; } .portrait { height: 80px; width: 30px; } .landscape { height: 30px; width: 80px; } .square { height: 75px; … Read more

How to lazy load images in ListView in Android

Here’s what I created to hold the images that my app is currently displaying. Please note that the “Log” object in use here is my custom wrapper around the final Log class inside Android. package com.wilson.android.library; /* Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)