thehardwareman:
I'm not sure what voltage the led require
Datasheets cited in #2. It's 1.4 ± 0.1 V
thehardwareman:
but if we assume 2 volt, the voltage over the resistor will be from 1 to 28 volt. At 1 volt the current flow will be 1 mA and 28 mA at 28V.
Cited in #2, 1 to 20 mA.
thehardwareman:
You must check the datasheet for the opto-coupler and see if 1 mA is sufficient and if 28 mA is too much.
There is no strict "sufficient" but 500 µA is cited. While not particularly linear, opto-couplers have a dynamic range of at least two or three orders of magnitude as per the datasheets cited in #2, I suspect much more given the dark current cited. You will note they are specified at a maximum of 50 mA.
thehardwareman:
If the min/max (required) current through the led is within this range,
It is specified from 500 µA to 50 mA, but not limited at the lower value.
thehardwareman:
then a resistor is OK. But if not, a constant current will solve this.
Nothing really to solve. A resistor is an awful lot simpler!
thehardwareman:
(and to complete what I did not manage to write before the forum went offline for a while)
It does that. However it specifically jacks up with references to "www.electroschematics.com" for some peculiar reason, which is from where that illustration comes and that is what actually prevented you from submitting your reply!

It took me ages to figure out how to get past it. 
thehardwareman:
As other has already said - the power dissipation can be high on the resistor. So 1/4 W is not enough. 1 W or more is required.
As cited in #2. Not however a major problem, as long as the source can supply the 20 mA.
Edit in 2024: Actually, the constant current circuit is not such a bad idea insofar as it does limit the overall power dissipation.
Note that the transistor itself is dissipating virtually all of the power at 30 V. So if we arranged a constant current of 5 mA, the dissipation would be less than 150 mW at 30 V and most transistors (rated of course at least 50V collector voltage) could readily handle this.