One way you can accomplish it is this way:
functions.php
add_action( 'wp_enqueue_scripts', 'your_lightbox_callback' );
function your_lightbox_callback(){
if( is_single() /* or whatever here */ ) {
wp_register_script( 'your-lightbox', get_bloginfo( 'template_url' ) . '/lightbox-class.js' );
wp_enqueue_script( 'your-lightbox' );
}
}
lightbox-class.js
var $j = jQuery.noConflict();
$j( document ).ready( function() {
$j( '#whereveryourpostsare img' ).addClass( 'lightbox' );
} );
Let me add that this hasn’t been tested, just typed here on the fly. If you try it do tell me if you have any issues, thanks!