Load current node from block and from display suite field Sorry if this question is too obvious, I need to load the current node from display suite and then execute this php code:

&lt;?php

$project = node_load(5);

foreach ($project-&gt;field_gallery['und'] as $val ) {
  echo '&lt;img src="' . $val['filename']  . '"&gt;';
}

?&gt;


In display suite I tried:  

$project = node_load($nid);

and

$project = $entity-&gt;nid;


I also tried the same within a block, and it failed. It only works when I set a static id as node_load(5).

Please, can I get the answer how to load the node from display suite custom field and from a simple block?  

Edit: I'm adding a custom field to display suite from this url:
 /admin/structure/ds/fields/manage_custom
Structure > Display Suite > Fields > Add a code field.
You can load the node id from node page using arg function...


  Returns a component of the current Drupal path.
  
  When viewing a page at the path "admin/structure/types", for example,
  arg(0) returns "admin", arg(1) returns "structure", and arg(2) returns
  "types".


node pages always has path 'node/nid' so arg(1) gives node id...

$nid = arg(1);
$node = node_load($nid);