Jump to content

Recommended Posts

Posted

For adding description to an image from API i use this code but i think it's to tricky because i need to save again the page for adding it....

<?php
...
$link->save();
if ($input->post->imageurl){
$link->images->add("..".$input->post->imageurl);
$link->save();
if ($input->post->alt){
	$link->images->first()->description = $input->post->alt;
	$link->save();
}
}

is there an easier way to do that?

Posted

I'm not completely sure, but shouldn't this work?

<?php
  $page->images->add(...);
  if ($input->post->alt) $page->images->last()->description = $input->post->alt;
  $page->save();

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...