Documentation

Add

int
CBlogImage::Add(
 array arFields
);

The method adds new image to a blog post.

Method parameters

ParameterDescription
arFields Array of the array("field"=>"value").
  • ID - image ID;
  • FILE_ID - file ID;
  • BLOG_ID - blog ID;
  • POST_ID - blog post ID;
  • USER_ID - user ID;
  • TIMESTAMP_X - time when a blog post is created;
  • TITLE - image title;
  • IMAGE_SIZE - image size in bytes;
  • IS_COMMENT - flag that specifies whether image is attached to a comment;
  • COMMENT_ID - ID of the comment to which the image is attached.

Returned value

The method returns ID of the added record, if the adding was successful. If an error occurs, the method will return false.

Examples of use

    $fileID = 2268;
	$file = CFile::GetFileArray($fileID);

	$res = CBlogImage::Add(
		array(
			"TITLE" => "image title",
			"FILE_ID" => $fileID,
			"BLOG_ID" => 1,
			"POST_ID" => 2,
			"USER_ID" => $USER->GetID(),
			"IMAGE_SIZE" => $file["FILE_SIZE"],
			"TIMESTAMP_X" => $DB->GetNowFunction(),
		)
	);

	if($res)
		echo 'Success';
  


© «Bitrix24», 2001-2024
Up