Revision 296 (by ahitrov, 2013/03/26 17:59:01) Promosite (anthill) project source
% if ( ref $document && $document->id ) {
%	my $image = $document->get_image ('picture');
%	if ( ref $image && exists $image->{filename} ) {
<card id="<% $document->id %>" url="<% $state->images_directory.$image->{filename} %>"/>
%	}
% }
<%args>

	$store	=> undef

</%args>
<%init>

  my $document;
  if ( $store ) {
	if ( $ARGS{picture} ) {
		$document = promosuite::Postcard->new ($keeper);
		my @properties = $document->structure();
		my ($prop) = grep { $_->{attr} eq 'picture' } @properties;
		my $IMG = $document->get_image ('picture');
		my $IMAGE = $m->comp ('/subs/set_image.msn',
			field	=> 'picture',
			object	=> $document,
			prop	=> $prop,
			default	=> $IMG,
			SETS	=> \%ARGS,
		);
		if (ref $IMAGE && exists($IMAGE->{filename})) {
			local $Data::Dumper::Indent = 0;
			$document->picture( Data::Dumper::Dumper($IMAGE) );
			$document->store;
		}
	}
  }
  return unless ref $document && $document->id;

</%init>