def add_photo
x = Struct.new(:image, :link, :type).new
yield x
if x[:image] && x[:link]
raise Vpim::InvalidEncodingError, 'Image is not allowed to be both inline and a link.'
end
value = x[:image] || x[:link]
if !value
raise Vpim::InvalidEncodingError, 'A image link or inline data must be provided.'
end
params = {}
params['TYPE'] = x[:type] if( x[:type] && x[:type].length > 0 )
if x[:link]
params['VALUE'] = 'URI'
else
params['ENCODING'] = :b64
if !x[:type]
raise Vpim::InvalidEncodingError, 'Inline image data must have it\'s type set.'
end
end
@card << Vpim::DirectoryInfo::Field.create( 'PHOTO', value, params )
self
end