Showing transparency slider by default in Layers Panel of QGIS?

This was briefly mentioned in QGIS - Developer forum where you need to use QgsMapLayer::setCustomPropertylayer to enable the embedded widget for your layer. We can then add an itemAdded event so that whenever a layer is added, it will automatically be shown with the transparency widget.

So you could use something like the following in the Python Console:

def transparency_slider():
    for layer in QgsMapLayerRegistry.instance().mapLayers().values():
        if layer.customProperty("embeddedWidgets/count") != 1 or layer.customProperty("embeddedWidgets/0/id") != u'transparency':
            layer.setCustomProperty("embeddedWidgets/count", 1)
            layer.setCustomProperty("embeddedWidgets/0/id", "transparency")         
        else:
            pass
        qgis.utils.iface.legendInterface().refreshLayerSymbology(layer)

# Connect "itemAdded" event to "transparency_slider" function
legend = qgis.utils.iface.legendInterface()
legend.itemAdded.connect(transparency_slider)

Tested on QGIS 2.18.3 for Win7 64-bit.


Example:

Inserting code into python console and before adding shapefiles:

Before

Result:

After


There is a plugin called Raster Transparency, that as the name suggests, will open a dockable panel with sliders for changing the transparency of a selected raster layer.

Go to Plugins > Manage and install plugins - Find it and install, a new associated icon will appear on your toolbars.