We present a generalized formalism for treating the porosity-associated reduction in continuum opacity that occurs when individual clumps in a stochastic medium become optically thick. As in previous work, we concentrate on developing bridging laws between the limits of optically thin and thick clumps. We consider geometries resulting in either isotropic or anisotropic effective opacity, and, in addition to an idealized model in which all clumps have the same local overdensity and scale, we also treat an ensemble of clumps with optical depths set by Markovian statistics. This formalism is then applied to the specific case of bound–free absorption of X-rays in hot star winds, a process not directly affected by clumping in the optically thin limit. We find that the Markov model gives surprisingly similar results to those found previously for the single-clump model, suggesting that porous opacity is not very sensitive to details of the assumed clump distribution function. Further, an anisotropic effective opacity favours escape of X-rays emitted in the tangential direction (the ‘venetian blind’ effect), resulting in a ‘bump’ of higher flux close to line centre as compared to profiles computed from isotropic porosity models. We demonstrate how this characteristic line shape may be used to diagnose the clump geometry, and we confirm previous results that for optically thick clumping to significantly influence X-ray line profiles, very large porosity lengths, defined as the mean free path between clumps, are required. Moreover, we present the first X-ray line profiles computed directly from line-driven instability simulations using a 3D patch method, and find that porosity effects from such models also are very small. This further supports the view that porosity has, at most, a marginal effect on X-ray line diagnostics in O stars, and therefore that these diagnostics do indeed provide a good ‘clumping insensitive’ method for deriving O star mass-loss rates.